#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V>& x) {
  cerr << '{';
  __print(x.first);
  cerr << ", ";
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T& x) {
  int first = 0;
  cerr << '{';
  for (auto& i : x) cerr << (first++ ? ", " : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001;
void solve() {
  int N, M;
  cin >> N >> M;
  map<int, int> cnt;
  int A[N];
  for (int i = 0; i < (N); i++) {
    int X;
    cin >> X;
    X--;
    A[i] = X;
    cnt[(i + N - X) % N]++;
  }
  vector<int> res;
  for (auto& a : cnt) {
    if (N - a.second > M * 2) {
      continue;
    }
    int B[N];
    for (int i = 0; i < (N); i++) {
      B[(i + N - a.first) % N] = A[i];
    }
    bool found[N];
    for (int i = 0; i < (N); i++) found[i] = false;
    int cur = N;
    for (int i = 0; i < (N); i++) {
      if (found[i]) continue;
      int p = i;
      cur--;
      while (!found[p]) {
        found[p] = true;
        p = B[p];
      }
    }
    if (cur <= M) {
      res.push_back(a.first);
    }
  }
  cout << (int)(res).size() << " ";
  for (auto& a : res) cout << a << " ";
  cout << nl;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
