#include <bits/stdc++.h>
using namespace std;
bool check(vector<int>& arr, int steps, int m) {
  int n = arr.size();
  vector<int> new_arr(n);
  for (int i = 0; i < n; i++) {
    new_arr[(i - steps + n) % n] = arr[i];
  }
  vector<int> visited(n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      count++;
      int pos = i;
      while (!visited[pos]) {
        visited[pos] = 1;
        pos = new_arr[pos];
      }
    }
  }
  return (n - count) <= m;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      arr[i]--;
    }
    map<int, int> count;
    for (int i = 0; i < n; i++) {
      int req = (i - arr[i] + n) % n;
      count[req]++;
    }
    vector<int> ans;
    for (auto var : count) {
      if (var.second >= n / 3) {
        if (check(arr, var.first, m)) ans.push_back(var.first);
      }
    }
    cout << ans.size() << " ";
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    cout << "\n";
  }
  return 0;
}
