#include"testlib.h"
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
 
using namespace std;
 
const int T = 1e4;
const int MAX_N = 2e5;
const int MAX_Q = 2e5;
 
int32_t main(int argc, char *argv[]) {
    registerGen(argc, argv, 1);
    cout << T << '\n';
    for (int i = 0; i < T; ++i) {
        int n = rnd.next(1, 3 * MAX_N / 2 / T);
        int q = rnd.next(1, 3 * MAX_Q / 2 / T);
        cout << n << ' ' << q << '\n';
        vector<int> a(n);
        iota(all(a), 1);
        for (int i = 0; i < n; ++i) cout << a[i] << " \n"[i + 1 == n];
        for (int i = 0; i < q; ++i) {
            int l = rnd.next(1, n), r = rnd.next(1, n);
            cout << min(l, r) << ' ' << max(l, r) << '\n';
        }
    }
}
