#include <bits/stdc++.h>
using namespace std;
inline void rd(int &x) { scanf("%d", &x); }
inline void rd(long long &x) { scanf("%lld", &x); }
inline void rd(double &x) { scanf("%lf", &x); }
inline void rd(char *s) { scanf("%s", s); }
template <typename T, typename... U>
inline void rd(T &a, U &...b) {
  rd(a), rd(b...);
}
const int maxn = 314514;
int pos[maxn], cnt[maxn], a[maxn], n, m;
int now[maxn], vis[maxn];
void dfs(int u) {
  vis[u] = 1;
  if (!vis[pos[now[u]]]) dfs(pos[now[u]]);
}
int chk(int k) {
  for (int i = 1; i <= n; ++i) now[i] = (i - k - 1 + n) % n + 1, vis[i] = 0;
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) ++cnt, dfs(i);
  return (n - cnt) <= m;
}
int main() {
  int T;
  rd(T);
  for (int kase = 1; kase <= T; ++kase) {
    rd(n, m);
    for (int i = 1; i <= n; ++i) rd(a[i]), pos[a[i]] = i, cnt[i] = 0;
    for (int i = 1; i <= n; ++i) {
      int dist = (pos[i] - i + n) % n;
      cnt[dist]++;
    }
    queue<int> ans;
    for (int k = 0; k <= n - 1; ++k)
      if (cnt[k] >= n - m * 2 && chk(k)) ans.push(k);
    printf("%d ", ans.size());
    while (ans.size()) printf("%d ", ans.front()), ans.pop();
    printf("\n");
  }
}
