#include<bits/stdc++.h>
const int N = 1e6+7;
using namespace std;
const int U = 1e6;
int c[N], fr[N], ans[N], pos[N];
#define pii pair<int, int>
#define lbt(x) (x &(-x))
pii query(int x) {
pii a; a.first = a.second = 0;
if(!x) return a;
while(x > 0) {
if(c[x] > a.first) a.first = c[x], a.second = pos[x];
else if(c[x] == a.first) a.second = min(a.second, pos[x]);
x -= lbt(x);
} return a;
}
void upd(int x, int a, int i) {
if(!x) return;
while(x <= n) {
//c[x] = max(c[x], a);
if(a > c[x]) {
c[x] = a;
pos[x] = i;
} else if(a == c[x]) pos[x] = min(i, pos[x]);
x += lbt(x);
}
}
int n;
int a[N], vis[N], ord[N];
int main() {
int T;
//scanf("%d", &T);
//cin >> T;
cin >> T;
vector<int> p;
set<int> s;
while(T--) {
scanf("%d", &n);
int jump = 0;
for(int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
ord[a[i]] = i;
pii nx = query(a[i] - 1);
ans[i] = nx.first + 1;
fr[i] = nx.second;
upd(a[i], ans[i], i);
if(ans[i] > ans[jump]) jump = i;
}
int Len = ans[jump];
while(jump) {
vis[jump] = 1;
jump = fr[jump];
}
//reverse(q.begin(), q.end());
for(int i = 1; i <= n; i++) {
if(vis[i]) {
set<int>::iterator it;
while((it = s.upper_bound(a[i])) != s.end()) {
p.push_back(ord[*it]);
s.erase(it);
}
}
s.insert(a[i]);
}
printf("%d %d\n", Len, p.size());
sort(p.begin(), p.end());
for(auto &x : p) printf("%d ", x);
printf("\n");
for(int i = 0; i <= n; i++) a[i] = vis[i] = ord[i] = c[i] = fr[i] = ans[i] = pos[i] = 0;
p.clear();
s.clear();
}
return 0;
}
/*
8
389 207 155 300 299 170 158 65
*/