#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MODULO_007 = 1000000007;
ll MODULO_009 = 1000000009;
ll MOD = MODULO_007;
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    int N;
    cin >> N;
    int posOp;
    cin >> posOp;
    vector<int> arr(N);
    vector<int> pos(N);
    for (int i = 0; i < N; i++) {
      cin >> arr[i];
      pos[arr[i] - 1] = i;
    }
    vector<int> shiftNeeded(N);
    for (int i = 0; i < N; i++) {
      shiftNeeded[i] = pos[i] - i;
      shiftNeeded[i] = (shiftNeeded[i] + N) % N;
    }
    vector<int> votesForShifts(N, 0);
    {
      for (int e : shiftNeeded) {
        votesForShifts[e]++;
      }
    }
    vector<int> resultingKs;
    for (int i = 0; i < N; i++) {
      if (votesForShifts[i] + 2 * posOp >= N) {
        vector<int> aftershifted(N);
        vector<int> reference(N);
        for (int j = 0; j < N; j++) {
          aftershifted[j] = ((j + N - i) % N);
          reference[j] = arr[j] - 1;
        }
        vector<pair<int, int>> vec(N, pair<int, int>(-1, -1));
        for (int j = 0; j < N; j++) {
          vec[aftershifted[j]].first = j;
          vec[reference[j]].second = j;
        }
        int needOps = 0;
        vector<bool> visited(N + 5, false);
        vector<vector<int>> neis(N + 5);
        for (int j = 0; j < N; j++) {
          if (vec[j].first == vec[j].second) continue;
          neis[vec[j].first].push_back(vec[j].second);
          neis[vec[j].second].push_back(vec[j].first);
        }
        for (int j = 0; j < N; j++) {
          if (visited[j]) {
            continue;
          }
          int compSize = 0;
          queue<int> q;
          q.push(j);
          while (!q.empty()) {
            int cur = q.front();
            q.pop();
            if (visited[cur]) {
              continue;
            }
            visited[cur] = true;
            compSize += 1;
            for (int a : neis[cur]) {
              if (visited[a]) {
                continue;
              }
              q.push(a);
            }
          }
          if (compSize > 1) {
            needOps += compSize - 1;
          }
        }
        if (needOps <= posOp) {
          resultingKs.push_back(i);
        }
      }
    }
    cout << resultingKs.size() << " ";
    sort(resultingKs.begin(), resultingKs.end());
    for (int e : resultingKs) {
      cout << e << " ";
    }
    cout << endl;
  }
  return 0;
}
