#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, mod = 1e9 + 7;
vector<int> g[N];
int cnt = 0;
bool mark[N];
void dfs(int v) {
  cnt++;
  mark[v] = true;
  for (int u : g[v]) {
    if (!mark[u]) {
      dfs(u);
    }
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    mp[(a[i] - i + n) % n]++;
  }
  vector<int> ans;
  for (pair<int, int> x : mp) {
    if (x.second < n / 3) {
      continue;
    }
    int val = (n - x.first) % n;
    int b[n];
    for (int i = 0; i < n; i++) {
      mark[i] = false;
      g[i].clear();
      b[i] = a[(i + val) % n];
      g[i].push_back(b[i]);
    }
    int t = 0;
    for (int i = 0; i < n; i++) {
      if (!mark[i]) {
        cnt = 0;
        dfs(i);
        t += cnt - 1;
      }
    }
    if (t > m) {
      continue;
    } else {
      ans.push_back(val);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << " ";
  for (int v : ans) {
    cout << v << " ";
  }
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  int cur = 1;
  while (t--) {
    solve();
  }
  return 0;
}
