#include <bits/stdc++.h>

using namespace std;
#define int int64_t

void solve() {
    int n, m;
    cin >> n >> m;
    vector<pair<int,int> > edge(m);
    vector<int> d(n + 1, 0);
    vector<int> f(n + 1, 0);
    for (int i = 0; i < m; i++) {
        cin >> edge[i].first >> edge[i].second;
        d[edge[i].first]++;
        f[edge[i].second]++;
    }
    cout << 0 << endl << 1 << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}





