using namespace std;
#include <bits/stdc++.h>

int main() {

    // Read in stuff.
    int n, size;
    string tmp;
    cin >> n >> size;

    set<string> stuff;
    for (int i=0; i<size; i++) {
        cin >> tmp;
        stuff.insert(tmp);
    }

    for (int i=0; i<n-1; i++) {

        set<string> next;
        for (int j=0; j<size; j++) {
            cin >> tmp;
            if (stuff.find(tmp) == stuff.end())
                continue;
            next.insert(tmp);
        }

        stuff = next;
    }

    cout << stuff.size() << endl;
    for (auto x: stuff)
        cout << x << endl;

    return 0;
}
