#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int main() {
int n, t;
cin >> n >> t;
vector<int64> masks(n);
for (int i = 0; i < t; ++i) {
int k;
cin >> k;
vector<int> a(k);
for (int &j : a) {
cin >> j; --j;
}
sort(a.begin(), a.end());
if (a[0] == 0) {
for (int j : a) masks[j] |= (1LL << i);
} else {
int64 mask = 0;
for (int j : a) mask |= masks[j];
for (int j : a) masks[j] = mask;
}
}
for (int i = 0; i < n; ++i) if (masks[i] == masks[0]) cout << i + 1 << '\n';
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIGludDY0ID0gbG9uZyBsb25nOwppbnQgbWFpbigpIHsKCWludCBuLCB0OyAKCWNpbiA+PiBuID4+IHQ7Cgl2ZWN0b3I8aW50NjQ+IG1hc2tzKG4pOwoJZm9yIChpbnQgaSA9IDA7IGkgPCB0OyArK2kpIHsKCQlpbnQgazsKCQljaW4gPj4gazsKCQl2ZWN0b3I8aW50PiBhKGspOwoJCWZvciAoaW50ICZqIDogYSkgewoJCQljaW4gPj4gajsgLS1qOwoJCX0KCQlzb3J0KGEuYmVnaW4oKSwgYS5lbmQoKSk7CgkJaWYgKGFbMF0gPT0gMCkgewoJCQlmb3IgKGludCBqIDogYSkgbWFza3Nbal0gfD0gKDFMTCA8PCBpKTsKCQl9IGVsc2UgewoJCQlpbnQ2NCBtYXNrID0gMDsKCQkJZm9yIChpbnQgaiA6IGEpIG1hc2sgfD0gbWFza3Nbal07CgkJCWZvciAoaW50IGogOiBhKSBtYXNrc1tqXSA9IG1hc2s7CgkJfQoJfQoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIGlmIChtYXNrc1tpXSA9PSBtYXNrc1swXSkgY291dCA8PCBpICsgMSA8PCAnXG4nOwoJcmV0dXJuIDA7Cn0=