#include <bits/stdc++.h>
#include "testlib.h"

#include "limits.h"

using ll = long long;

int main(int argc, char** argv) {
    registerValidation(argc, argv);

    const std::string REGEX = "[a-z]{1," + std::to_string(LEN) + "}";

    int t = inf.readInt(1, T, "t");
    inf.readEoln();
    int sumN = 0;
    for (int ti = 0; ti < t; ++ti) {
        setTestCase(ti + 1);

        int n = inf.readInt(2, N, "n");
        inf.readEoln();
        std::set<std::pair<std::string, std::string>> used;
        for (int i = 0; i < n; ++i) {
            std::string x = inf.readWord(REGEX, format("x[%d]", i + 1));
            inf.readSpace();
            std::string y = inf.readWord(REGEX, format("y[%d]", i + 1));
            inf.readEoln();
            ensuref(used.emplace(x, y).second, format("Problem [%d] coincides with previous one", i + 1).c_str());
        }

        sumN += n;
        ensuref(sumN <= N, "SumN exceeds maximum limit");
    }
    inf.readEof();

    return 0;
}
