#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
const int mxN = 3e5;
int n, m, t, a[mxN], cnt[mxN];
bool vis[mxN];
int main() {
  cin >> t;
  for (; t > 0; --t) {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
      cin >> a[i], --a[i];
    }
    memset(cnt, 0, sizeof(int) * n);
    for (int i = 0; i < n; ++i) {
      ++cnt[(a[i] + n - i - 1) % n];
    }
    vector<int> cand;
    for (int i = 0; i < n; ++i) {
      if (cnt[i] >= n / 3) {
        memset(vis, 0, sizeof(int) * n);
        int swp = n;
        for (int j = 0; j < n; ++j) {
          int p = j;
          if (!vis[p]) --swp;
          while (!vis[p]) {
            vis[p] = true;
            p = a[(p + n - i - 1) % n];
          }
        }
        if (swp <= m) {
          cand.push_back(n - i - 1);
        }
      }
    }
    cout << cand.size() << ' ';
    sort(cand.begin(), cand.end());
    for (auto& item : cand) cout << item << ' ';
    cout << '\n';
  }
}
