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

using namespace std;

int main(int argc, char* argv[]) {
    registerValidation(argc, argv);
    int t = inf.readInt(1, 10'000, "t");
    inf.readEoln();
    int sum_n = 0, sum_m = 0;
    for (int tc = 1; tc <= t; ++tc) {
        setTestCase(tc);
        int n = inf.readInt(2, 200'000, "n");
        inf.readSpace();
        int m = inf.readInt(1, 200'000, "m");
        inf.readEoln();
        sum_n += n;
        ensuref(sum_n <= 200'000, "Sum of n should not exceed 2e5");
        sum_m += n;
        ensuref(sum_m <= 200'000, "Sum of m should not exceed 2e5");
        for (int j = 0; j < m; ++j) {
            int v = inf.readInt(1, n, "v");
            inf.readSpace();
            int u = inf.readInt(1, n, "u");
            inf.readEoln();
            ensuref(v != u, "v, u should be different (%d == %d)", v, u);
        }
    }
    inf.readEof();
}