#include <bits/stdc++.h>
using namespace std;
namespace start {
const int inf = INT_MAX >> 1;
long long read() {
  long long x;
  if (scanf("%lld", &x) != 1) exit(0);
  return x;
}
void print(long long x, bool e = 0) { printf("%lld%c", x, " \n"[e]); }
const int N = 500010;
}  // namespace start
using namespace start;
int Count(int a[], int n) {
  static bool vis[N];
  int cnt = 0;
  fill(vis, vis + n, 0);
  for (int i = (0), ib = (n); i < ib; i++)
    if (!vis[i]) {
      for (int p = a[i]; p != i; p = a[p]) vis[p] = 1;
      cnt++;
    }
  return cnt;
}
vector<int> ans;
int a[N], cnt[N];
int b[N];
void Solve() {
  ans.clear();
  int n = read(), k = read();
  fill(cnt, cnt + n, 0);
  for (int i = (0), ib = (n); i < ib; i++) {
    a[i] = read() - 1;
    cnt[(i + n - a[i]) % n]++;
  }
  for (int i = (0), ib = (n); i < ib; i++) {
    if (cnt[i] >= n / 3) {
      for (int j = (0), ib = (n); j < ib; j++) b[j] = a[(j + i) % n];
      if (n - Count(b, n) <= k) ans.push_back(i);
    }
  }
  sort(ans.begin(), ans.end());
  print(ans.size());
  for (int i = (0), ib = (ans.size()); i < ib; i++) print(ans[i], i == ib - 1);
}
signed main() {
  int T = 1;
  T = read();
  for (int ca = (1), ib = (T + 1); ca < ib; ca++) {
    Solve();
  }
  return 0;
}
