#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
long long a[300005], n, m, c[300005], pre[300005];
long long find(long long x) {
  return (x == pre[x]) ? x : (pre[x] = find(pre[x]));
}
void merge(long long x, long long y) { pre[find(x)] = find(y); }
bool check(long long x) {
  long long now = 1, num = 0;
  for (long long i = 1; i <= n; i++) {
    pre[i] = i;
  }
  for (long long i = x + 1; i <= n; i++) {
    c[i] = now++;
  }
  for (long long i = 1; i <= x; i++) {
    c[i] = now++;
  }
  for (long long i = 1; i <= n; i++) {
    merge(c[i], a[i]);
  }
  for (long long i = 1; i <= n; i++) {
    if (i != find(i)) num++;
  }
  return num <= m;
}
int main() {
  long long q;
  cin >> q;
  while (q--) {
    cin >> n >> m;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
    }
    map<long long, long long> p;
    for (long long i = 1; i <= n; i++) {
      long long v = i - a[i];
      if (v < 0) v += n;
      p[v]++;
    }
    vector<long long> ans, d;
    for (auto i : p) {
      if (i.second >= n - m * 2) {
        ans.push_back(i.first);
      }
    }
    for (auto i : ans) {
      if (check(i)) d.push_back(i);
    }
    cout << d.size() << " ";
    for (auto i : d) {
      cout << i << " ";
    }
    cout << endl;
  }
}
