description: An identity permutation of length n is an array [1, 2, 3, ..., n].
  
  We performed the following operations to an identity permutation of length n:
  
    * firstly, we cyclically shifted it to the right by k positions, where k is unknown to you (the only thing you know is that 0 ≤ k ≤ n - 1). When an array is cyclically shifted to the right by k positions, the resulting array is formed by taking k last elements of the original array (without changing their relative order), and then appending n - k first elements to the right of them (without changing relative order of the first n - k elements as well). For example, if we cyclically shift the identity permutation of length 6 by 2 positions, we get the array [5, 6, 1, 2, 3, 4]; 
    * secondly, we performed the following operation at most m times: pick any two elements of the array and swap them. 
  
  
  
  You are given the values of n and m, and the resulting array. Your task is to find all possible values of k in the cyclic shift operation.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases.
  
  Each test case consists of two lines. The first line contains two integers n and m (3 ≤ n ≤ 3 ⋅ 10^5; 0 ≤ m ≤ n/3).
  
  The second line contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, each integer from 1 to n appears in this sequence exactly once) — the resulting array.
  
  The sum of n over all test cases does not exceed 3 ⋅ 10^5.
  
  Output
  
  For each test case, print the answer in the following way:
  
    * firstly, print one integer r (0 ≤ r ≤ n) — the number of possible values of k for the cyclic shift operation; 
    * secondly, print r integers k_1, k_2, ..., k_r (0 ≤ k_i ≤ n - 1) — all possible values of k in increasing order. 
  
  Example
  
  Input
  
  
  4
  4 1
  2 3 1 4
  3 1
  1 2 3
  3 1
  3 2 1
  6 0
  1 2 3 4 6 5
  
  
  Output
  
  
  1 3
  1 0
  3 0 1 2
  0
  
  Note
  
  Consider the example: 
  
    * in the first test case, the only possible value for the cyclic shift is 3. If we shift [1, 2, 3, 4] by 3 positions, we get [2, 3, 4, 1]. Then we can swap the 3-rd and the 4-th elements to get the array [2, 3, 1, 4]; 
    * in the second test case, the only possible value for the cyclic shift is 0. If we shift [1, 2, 3] by 0 positions, we get [1, 2, 3]. Then we don't change the array at all (we stated that we made at most 1 swap), so the resulting array stays [1, 2, 3]; 
    * in the third test case, all values from 0 to 2 are possible for the cyclic shift: 
      * if we shift [1, 2, 3] by 0 positions, we get [1, 2, 3]. Then we can swap the 1-st and the 3-rd elements to get [3, 2, 1]; 
      * if we shift [1, 2, 3] by 1 position, we get [3, 1, 2]. Then we can swap the 2-nd and the 3-rd elements to get [3, 2, 1]; 
      * if we shift [1, 2, 3] by 2 positions, we get [2, 3, 1]. Then we can swap the 1-st and the 2-nd elements to get [3, 2, 1]; 
    * in the fourth test case, we stated that we didn't do any swaps after the cyclic shift, but no value of cyclic shift could produce the array [1, 2, 3, 4, 6, 5]. 
solution: import java.io.OutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.util.Arrays;
  import java.io.IOException;
  import java.lang.reflect.Field;
  import java.nio.charset.StandardCharsets;
  import java.io.UncheckedIOException;
  import java.io.Closeable;
  import java.io.InputStream;
  
  /**
   * Built using CHelper plug-in
   * Actual solution is at the top
   */
  public class Main {
      public static void main(String[] args) throws Exception {
          Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
          thread.start();
          thread.join();
      }
  
      static class TaskAdapter implements Runnable {
          @Override
          public void run() {
              InputStream inputStream = System.in;
              OutputStream outputStream = System.out;
              FastInput in = new FastInput(inputStream);
              FastOutput out = new FastOutput(outputStream);
              EPermutationShift solver = new EPermutationShift();
              int testCount = Integer.parseInt(in.next());
              for (int i = 1; i <= testCount; i++)
                  solver.solve(i, in, out);
              out.close();
          }
      }
  
      static class EPermutationShift {
          public void solve(int testNumber, FastInput in, FastOutput out) {
              int n = in.ri();
              int m = in.ri();
              int atleast = n - 2 * m;
              int[] p = new int[n];
              for (int i = 0; i < n; i++) {
                  p[i] = in.ri() - 1;
              }
              int[] occur = new int[n];
              for (int i = 0; i < n; i++) {
                  //a[i] + r = i
                  //r = i - a[i];
                  int indicate = i - p[i];
                  indicate = DigitUtils.mod(indicate, n);
                  occur[indicate]++;
              }
              IntegerArrayList ans = new IntegerArrayList();
              int[] clone = new int[n];
              for (int i = 0; i < n; i++) {
                  if (occur[i] < atleast) {
                      continue;
                  }
                  System.arraycopy(p, 0, clone, 0, n);
                  int req = test(clone, i);
                  if (req <= m) {
                      ans.add(i);
                  }
              }
              out.append(ans.size()).append(' ');
              for (int x : ans.toArray()) {
                  out.append(x).append(' ');
              }
              out.println();
          }
  
          public int test(int[] p, int r) {
              int n = p.length;
              for (int i = 0; i < n; i++) {
                  p[i] += r;
                  p[i] = DigitUtils.mod(p[i], n);
              }
              Permutation perm = new Permutation(p);
              int c = perm.countCircles();
              return n - c;
          }
  
      }
  
      static class FastOutput implements AutoCloseable, Closeable, Appendable {
          private static final int THRESHOLD = 32 << 10;
          private OutputStream writer;
          private StringBuilder cache = new StringBuilder(THRESHOLD * 2);
          private static Field stringBuilderValueField;
          private char[] charBuf = new char[THRESHOLD * 2];
          private byte[] byteBuf = new byte[THRESHOLD * 2];
  
          static {
              try {
                  stringBuilderValueField = StringBuilder.class.getSuperclass().getDeclaredField("value");
                  stringBuilderValueField.setAccessible(true);
              } catch (Exception e) {
                  stringBuilderValueField = null;
              }
              stringBuilderValueField = null;
          }
  
          public FastOutput append(CharSequence csq) {
              cache.append(csq);
              return this;
          }
  
          public FastOutput append(CharSequence csq, int start, int end) {
              cache.append(csq, start, end);
              return this;
          }
  
          private void afterWrite() {
              if (cache.length() < THRESHOLD) {
                  return;
              }
              flush();
          }
  
          public FastOutput(OutputStream writer) {
              this.writer = writer;
          }
  
          public FastOutput append(char c) {
              cache.append(c);
              afterWrite();
              return this;
          }
  
          public FastOutput append(int c) {
              cache.append(c);
              afterWrite();
              return this;
          }
  
          public FastOutput println() {
              return append('\n');
          }
  
          public FastOutput flush() {
              try {
                  if (stringBuilderValueField != null) {
                      try {
                          byte[] value = (byte[]) stringBuilderValueField.get(cache);
                          writer.write(value, 0, cache.length());
                      } catch (Exception e) {
                          stringBuilderValueField = null;
                      }
                  }
                  if (stringBuilderValueField == null) {
                      int n = cache.length();
                      if (n > byteBuf.length) {
                          //slow
                          writer.write(cache.toString().getBytes(StandardCharsets.UTF_8));
  //                writer.append(cache);
                      } else {
                          cache.getChars(0, n, charBuf, 0);
                          for (int i = 0; i < n; i++) {
                              byteBuf[i] = (byte) charBuf[i];
                          }
                          writer.write(byteBuf, 0, n);
                      }
                  }
                  writer.flush();
                  cache.setLength(0);
              } catch (IOException e) {
                  throw new UncheckedIOException(e);
              }
              return this;
          }
  
          public void close() {
              flush();
              try {
                  writer.close();
              } catch (IOException e) {
                  throw new UncheckedIOException(e);
              }
          }
  
          public String toString() {
              return cache.toString();
          }
  
      }
  
      static class SequenceUtils {
          public static boolean equal(int[] a, int al, int ar, int[] b, int bl, int br) {
              if ((ar - al) != (br - bl)) {
                  return false;
              }
              for (int i = al, j = bl; i <= ar; i++, j++) {
                  if (a[i] != b[j]) {
                      return false;
                  }
              }
              return true;
          }
  
      }
  
      static class Permutation {
          int[] g;
          int[] idx;
          int[] l;
          int[] r;
          int n;
  
          public int countCircles() {
              int ans = 0;
              for (int i = 0; i < n; i = r[i] + 1) {
                  ans++;
              }
              return ans;
          }
  
          public Permutation(int[] p) {
              this(p, p.length);
          }
  
          public Permutation(int[] p, int len) {
              n = len;
              boolean[] visit = new boolean[n];
              g = new int[n];
              l = new int[n];
              r = new int[n];
              idx = new int[n];
              int wpos = 0;
              for (int i = 0; i < n; i++) {
                  int val = p[i];
                  if (visit[val]) {
                      continue;
                  }
                  visit[val] = true;
                  g[wpos] = val;
                  l[wpos] = wpos;
                  idx[val] = wpos;
                  wpos++;
                  while (true) {
                      int x = p[g[wpos - 1]];
                      if (visit[x]) {
                          break;
                      }
                      visit[x] = true;
                      g[wpos] = x;
                      l[wpos] = l[wpos - 1];
                      idx[x] = wpos;
                      wpos++;
                  }
                  for (int j = l[wpos - 1]; j < wpos; j++) {
                      r[j] = wpos - 1;
                  }
              }
          }
  
          public int apply(int x, int p) {
              int i = idx[x];
              int dist = DigitUtils.mod((i - l[i]) + p, r[i] - l[i] + 1);
              return g[dist + l[i]];
          }
  
          public String toString() {
              StringBuilder builder = new StringBuilder();
              for (int i = 0; i < n; i++) {
                  builder.append(apply(i, 1)).append(' ');
              }
              return builder.toString();
          }
  
      }
  
      static class DigitUtils {
          private DigitUtils() {
          }
  
          public static int mod(int x, int mod) {
              if (x < -mod || x >= mod) {
                  x %= mod;
              }
              if (x < 0) {
                  x += mod;
              }
              return x;
          }
  
      }
  
      static class FastInput {
          private final InputStream is;
          private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
          private byte[] buf = new byte[1 << 13];
          private int bufLen;
          private int bufOffset;
          private int next;
  
          public FastInput(InputStream is) {
              this.is = is;
          }
  
          private int read() {
              while (bufLen == bufOffset) {
                  bufOffset = 0;
                  try {
                      bufLen = is.read(buf);
                  } catch (IOException e) {
                      bufLen = -1;
                  }
                  if (bufLen == -1) {
                      return -1;
                  }
              }
              return buf[bufOffset++];
          }
  
          public void skipBlank() {
              while (next >= 0 && next <= 32) {
                  next = read();
              }
          }
  
          public String next() {
              return readString();
          }
  
          public int ri() {
              return readInt();
          }
  
          public int readInt() {
              boolean rev = false;
  
              skipBlank();
              if (next == '+' || next == '-') {
                  rev = next == '-';
                  next = read();
              }
  
              int val = 0;
              while (next >= '0' && next <= '9') {
                  val = val * 10 - next + '0';
                  next = read();
              }
  
              return rev ? val : -val;
          }
  
          public String readString(StringBuilder builder) {
              skipBlank();
  
              while (next > 32) {
                  builder.append((char) next);
                  next = read();
              }
  
              return builder.toString();
          }
  
          public String readString() {
              defaultStringBuf.setLength(0);
              return readString(defaultStringBuf);
          }
  
      }
  
      static class IntegerArrayList implements Cloneable {
          private int size;
          private int cap;
          private int[] data;
          private static final int[] EMPTY = new int[0];
  
          public IntegerArrayList(int cap) {
              this.cap = cap;
              if (cap == 0) {
                  data = EMPTY;
              } else {
                  data = new int[cap];
              }
          }
  
          public IntegerArrayList(int[] data) {
              this(0);
              addAll(data);
          }
  
          public IntegerArrayList(IntegerArrayList list) {
              this.size = list.size;
              this.cap = list.cap;
              this.data = Arrays.copyOf(list.data, size);
          }
  
          public IntegerArrayList() {
              this(0);
          }
  
          public void ensureSpace(int req) {
              if (req > cap) {
                  while (cap < req) {
                      cap = Math.max(cap + 10, 2 * cap);
                  }
                  data = Arrays.copyOf(data, cap);
              }
          }
  
          public void add(int x) {
              ensureSpace(size + 1);
              data[size++] = x;
          }
  
          public void addAll(int[] x) {
              addAll(x, 0, x.length);
          }
  
          public void addAll(int[] x, int offset, int len) {
              ensureSpace(size + len);
              System.arraycopy(x, offset, data, size, len);
              size += len;
          }
  
          public void addAll(IntegerArrayList list) {
              addAll(list.data, 0, list.size);
          }
  
          public int size() {
              return size;
          }
  
          public int[] toArray() {
              return Arrays.copyOf(data, size);
          }
  
          public String toString() {
              return Arrays.toString(toArray());
          }
  
          public boolean equals(Object obj) {
              if (!(obj instanceof IntegerArrayList)) {
                  return false;
              }
              IntegerArrayList other = (IntegerArrayList) obj;
              return SequenceUtils.equal(data, 0, size - 1, other.data, 0, other.size - 1);
          }
  
          public int hashCode() {
              int h = 1;
              for (int i = 0; i < size; i++) {
                  h = h * 31 + Integer.hashCode(data[i]);
              }
              return h;
          }
  
          public IntegerArrayList clone() {
              IntegerArrayList ans = new IntegerArrayList();
              ans.addAll(this);
              return ans;
          }
  
      }
  }
  
  