#include "testlib.h"

using namespace std;

int main() {
    registerValidation();
    int n = inf.readInt(2, 100000);
    inf.readSpace();
    int m = inf.readInt(1, 100000);
    inf.readEoln();
    int sumK = 0;
    for(int i = 0; i < m; ++i) {
        int k = inf.readInt(1, n);
        sumK += k;
        std::vector<int> participants;
        for(int t = 0; t < k; ++t) {
            inf.readSpace();
            participants.push_back(inf.readInt(1, n));
        }
        inf.readEoln();

        std::sort(participants.begin(), participants.end());
        ensure(unique(participants.begin(), participants.end()) == participants.end());
    }
    ensure(sumK <= 100000);
    inf.readEof();
    return 0;
}
