#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, m;
    cin >> n >> m;
    vector<long long> p(n);
    for (long long z = 0; (1 > 0 and z < n) or (1 < 0 and z > n); z += 1)
      cin >> p[z];
    ;
    function<long long(long long)> num_swaps = [&](long long k) {
      vector<long long> b(n);
      for (long long i = 0; (1 > 0 and i < n) or (1 < 0 and i > n); i += 1)
        b[i] = (i - k + n) % n + 1;
      vector<vector<long long> > g(n, vector<long long>());
      ;
      for (long long i = 0; (1 > 0 and i < n) or (1 < 0 and i > n); i += 1) {
        g[p[i] - 1].push_back(b[i] - 1);
        g[b[i] - 1].push_back(p[i] - 1);
      }
      vector<bool> v(n, false);
      function<void(long long)> dfs = [&](long long rt) {
        v[rt] = true;
        for (auto ch : g[rt])
          if (!v[ch]) dfs(ch);
      };
      long long c = 0;
      for (long long i = 0; (1 > 0 and i < n) or (1 < 0 and i > n); i += 1)
        if (!v[i]) {
          dfs(i);
          ++c;
        }
      return n - c;
    };
    vector<long long> cnt(n, 0);
    for (long long i = 0; (1 > 0 and i < n) or (1 < 0 and i > n); i += 1)
      ++cnt[(i + 1 - p[i] + n) % n];
    vector<long long> ans;
    for (long long k = 0; (1 > 0 and k < n) or (1 < 0 and k > n); k += 1)
      if (cnt[k] >= n - m * 2 and num_swaps(k) <= m) ans.push_back(k);
    cout << ans.size();
    for (auto x : ans) cout << " " << x;
    cout << endl;
  }
  return 0;
}
