#include using namespace std; #define rep(i,n) for(int i = 0;i < (n);i++) int main(){ int t; cin >> t; vector> ans(t); rep(i,t){ int n; cin >> n; vector p(n); map mp; rep(j,n) cin >> p[j],mp[--p[j]] = j; rep(j,n){ int cnt = mp[j]; if(p[cnt] == cnt)continue; cnt--; int flag = 1; while(cnt >= j ){ if(p[cnt] == cnt){ flag = -1;break; }else swap(p[cnt],p[cnt+1]); ans[i].push_back(cnt+1); cnt--; } if(flag == -1){ ans[i].clear(); ans[i].push_back(-1); break; } } } rep(i,t){ if(ans[i].size() == 1 && ans[i][0] == -1)cout << -1 << endl; else{ cout << ans[i].size() << endl; rep(j,ans[i].size()){ cout << ans[i][j] << " "; } cout << endl; } } return 0; }