#include <bits/stdc++.h>
using namespace std;
const long long DIM = 3e5 + 7;
const long long DIMM = 5e4 + 7;
const long long DDIM = 7;
const long long INF = 1e18 + 7;
const long long X = 1e5 + 7;
const long long BS = 2e5 + 7;
const long long AS = 26 + 7;
const long long MODULO = 1e9 + 7;
long long nt, n, m, k, q;
long long val, s, n1;
long long a[DIM], b[DIM], p[DIM], p1[DIM], c[DIM];
vector<long long> res, res1;
bool check(long long s) {
  long long m1 = m, v;
  for (int i = 1; i <= n; i++) {
    b[i] = a[i];
    p1[i] = p[i];
  }
  for (int i = 1; i <= n; i++) {
    v = ((i - s + n - 1) % n + 1);
    if (b[i] != v) {
      if (m1 > 0) {
        p1[b[i]] = p1[v];
        swap(b[i], b[p1[v]]);
        p1[v] = i;
        m1--;
      } else
        return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio();
  cin.tie();
  cout.tie();
  ;
  cin >> nt;
  for (int tt = 1; tt <= nt; tt++) {
    cin >> n >> m;
    n1 = n - 2 * m;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      p[a[i]] = i;
      if (i < a[i])
        s = n - a[i] + i;
      else
        s = i - a[i];
      c[s]++;
    }
    for (int i = 0; i < n; i++) {
      if (c[i] >= n1) res1.push_back(i);
      c[i] = 0;
    }
    for (auto to : res1) {
      if (check(to)) res.push_back(to);
    }
    cout << res.size() << ' ';
    for (auto to : res) cout << to << ' ';
    cout << endl;
    res.clear();
    res1.clear();
  }
  return 0;
}
