#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int n, m;
int arr[300005];
int pos[300005];
int distVals[300005];
int graph[300005];
int resPerm[300005];
bool vis[300005];
int dfs(int x) {
  vis[x] = true;
  if (vis[graph[x]]) return 1;
  return 1 + dfs(graph[x]);
}
bool works(int k) {
  for (int i = n - k; i < n; ++i) resPerm[i - (n - k)] = i;
  for (int i = 0; i < n - k; ++i) resPerm[i + k] = i;
  for (int i = 0; i < n; ++i) {
    graph[i] = (pos[resPerm[i]]);
    vis[i] = false;
  }
  vector<int> sizes;
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) sizes.push_back(dfs(i));
  }
  int ans = 0;
  for (int x : sizes) ans += (x - 1);
  if (ans <= m) return true;
  return false;
}
void doIt() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    distVals[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    --arr[i];
    pos[arr[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    int d = (pos[i] - i);
    d = (d + n) % n;
    distVals[d]++;
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    if (distVals[i] < n - 2 * m) continue;
    if (works(i)) ans.push_back(i);
  }
  cout << ans.size() << " ";
  for (int x : ans) cout << x << " ";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) doIt();
  return 0;
}
