#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e9 + 9;
vector<long long> adj[300009];
long long vis[300009];
long long n, m;
void dfs(long long x) {
  vis[x] = 1;
  for (auto e : adj[x]) {
    if (vis[e] == -1) dfs(e);
  }
}
long long calculate(vector<long long> need, long long k) {
  long long have[n + 2];
  for (long long i = 0; i < (n); ++i) {
    vis[i] = -1;
    adj[i].clear();
  }
  for (long long i = 0; i < (n); ++i) {
    have[i] = i - k;
    if (have[i] < 0) have[i] += n;
  }
  for (long long i = 0; i < (n); ++i) {
    if (need[i] != have[i]) {
      adj[need[i]].push_back(have[i]);
      adj[have[i]].push_back(need[i]);
    }
  }
  long long comp = 0;
  for (long long i = 0; i < (n); ++i) {
    if (vis[i] == -1) {
      dfs(i);
      comp++;
    }
  }
  return (long long)(need).size() - comp;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<long long> vet(n);
    for (long long i = 0; i < (n); ++i) {
      cin >> vet[i];
      vet[i]--;
    }
    long long cont[n + 2];
    vector<long long> ans;
    memset(cont, 0, sizeof cont);
    for (long long i = 0; i < (n); ++i) {
      long long pos = i - vet[i];
      if (pos < 0) pos += n;
      cont[pos]++;
    }
    for (long long i = 0; i < (n); ++i) {
      if (cont[i] >= (n + 2) / 3 && calculate(vet, i) <= m) {
        ans.push_back(i);
      }
    }
    cout << (long long)(ans).size();
    if ((long long)(ans).size() > 0) {
      for (long long i = 0; i < ((long long)(ans).size()); ++i) {
        cout << " " << ans[i];
      }
    }
    cout << "\n";
  }
  return 0;
}
