#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<utility>

using namespace std;
int n, f;//count
map<pair<string,string>,int> il;//itemlist
multimap<string,string>ans;


int main(){
	cin >> n >> f;

	for(int i=0; i<n; i++){
		int m;
		cin >> m;
		string s[15];
		for(int j=0; j < m; j++){
			cin >> s[j];
			for(int k=0; k < j; k++){
				string tmp[2] = {s[k], s[j]};
				sort(tmp, tmp+2);
				if(il.count(make_pair(tmp[0], tmp[1])) == 0) il.insert(make_pair(make_pair(tmp[0], tmp[1]),1));
				else {
					il[make_pair(tmp[0],tmp[1])]++;
				}
			}
		}
	}

	for(auto itr = il.begin(); itr != il.end(); itr++){
		if((*itr).second >= f){
			ans.insert((*itr).first);
		}
	}

	cout << ans.size() << endl;

	for(auto itr=ans.begin(); itr != ans.end(); itr++){
		cout << (*itr).first << ' ' << (*itr).second << endl;
	}

    return 0;
}

