#include<bits/stdc++.h> usingnamespace std; constint maxn = 2e5 + 10; int a[maxn], b[maxn]; int n, k; boolcheck(int x){ int num = 0; for (int i = 1; i + x <= n; i++) { num = max(num, b[i+x] - b[i-1]); } return num - (n - num) >= k; } voidsolver(){ memset(b, 0, sizeof(b)); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i], ++b[a[i]]; for (int i = 1; i <= n; i++) b[i] += b[i-1]; int l = 0, r = n-1; // 二分查找最小的 y - x while (l < r) { int mid = (l+r) >> 1; if (check(mid)) { r = mid; } else { l = mid + 1; } } int x, num = 0; for (int i = 1; i <= n-l; i++) { if (b[i+l] - b[i-1] >= num) num = b[i+l] - b[i-1], x = i; } cout << x << ' ' << x + l << endl; num = 0; int now = 0, last = 1; for (int i = 1; i < k; i++) { while (num <= 0) { now++; if (a[now] >= x && a[now] <= x + l) num++; else num--; } cout << last << ' ' << now << endl; num = 0, last = now + 1; } cout << last << ' ' << n << endl; } intmain(){ int _ = 1; cin >> _; while (_--) { solver(); } return0; }