#include <bits/stdc++.h>
using namespace std;
long long ans;
long long n, m, t, a[300001], b[300001], c[300001];
long long i, j, k, realm;
vector<long long> vec;
void solution() {
  cin >> n;
  ;
  cin >> m;
  ;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    ;
    a[i]--;
    b[i] = 0;
  }
  for (i = 0; i < n; i++) {
    b[(n + i - a[i]) % n]++;
  }
  for (k = 0; k < n; k++) {
    if (b[k] >= n / 3) {
      for (i = 0; i < n; i++) {
        if ((n + i - a[i]) % n == k) {
          c[i] = 1;
        } else {
          c[i] = 0;
        }
      }
      realm = 0;
      for (i = 0; i < n; i++) {
        if (c[i] == 0) {
          c[i] = 1;
          j = (a[i] + k) % n;
          while (c[j] == 0) {
            c[j] = 1;
            j = (a[j] + k) % n;
            realm++;
          }
        }
      }
      if (realm <= m) {
        vec.push_back(k);
      }
    }
  }
  cout << vec.size();
  ;
  for (i = 0; i < vec.size(); i++) {
    cout << ' ';
    ;
    cout << vec[i];
    ;
  }
  cout << '\n';
  ;
  vec.clear();
}
int main() {
  ios::sync_with_stdio(false);
  long long ttt;
  cin >> ttt;
  ;
  while (ttt--) {
    solution();
  }
  return 0;
}
