description: This is an interactive problem. The only difference between the easy and hard version is the limit on number of questions.
  
  There are n players labelled from 1 to n. It is guaranteed that n is a multiple of 3.
  
  Among them, there are k impostors and n-k crewmates. The number of impostors, k, is not given to you. It is guaranteed that n/3 < k < 2n/3.
  
  In each question, you can choose three distinct integers a, b, c (1 ≤ a, b, c ≤ n) and ask: "Among the players labelled a, b and c, are there more impostors or more crewmates?" You will be given the integer 0 if there are more impostors than crewmates, and 1 otherwise.
  
  Find the number of impostors k and the indices of players that are impostors after asking at most n+6 questions.
  
  The jury is adaptive, which means the indices of impostors may not be fixed beforehand and can depend on your questions. It is guaranteed that there is at least one set of impostors which fulfills the constraints and the answers to your questions at any time.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.
  
  The first and only line of each test case contains a single integer n (6 ≤ n < 10^4, n is a multiple of 3) — the number of players.
  
  It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^4.
  
  Interaction
  
  For each test case, the interaction starts with reading n.
  
  Then you are allowed to make at most n+6 questions in the following way:
  
  "? a b c" (1 ≤ a, b, c ≤ n, a, b and c are pairwise distinct).
  
  After each one, you should read an integer r, which is equal to 0 if there are more impostors than crewmates among players labelled a, b and c, and equal to 1 otherwise.
  
  Answer -1 instead of 0 or 1 means that you made an invalid query. Exit immediately after receiving -1 and you will see Wrong answer verdict. Otherwise you can get an arbitrary verdict because your solution will continue to read from a closed stream.
  
  When you have found the indices of all impostors, print a single line "! " (without quotes), followed by the number of impostors k, followed by k integers representing the indices of the impostors. Please note that you must print all this information on the same line. 
  
  After printing the answer, your program must then continue to solve the remaining test cases, or exit if all test cases have been solved.
  
  After printing the queries and answers do not forget to output end of line and flush the output buffer. Otherwise, you will get the Idleness limit exceeded verdict. To do flush use:
  
    * fflush(stdout) or cout.flush() in C++; 
    * System.out.flush() in Java; 
    * flush(output) in Pascal; 
    * stdout.flush() in Python; 
    * Read documentation for other languages. 
  
  
  
  Hacks
  
  You cannot make hacks in this problem.
  
  Example
  
  Input
  
  
  2
  6
  
  0
  
  1
  
  9
  
  1
  
  Output
  
  
  ? 1 2 3
  
  ? 3 4 5
  
  ! 3 4 1 2
  
  ? 7 1 9
  
  ! 4 2 3 6 8
  
  Note
  
  Explanation for example interaction (note that this example only exists to demonstrate the interaction procedure and does not provide any hint for the solution):
  
  For the first test case:
  
  Question "? 1 2 3" returns 0, so there are more impostors than crewmates among players 1, 2 and 3.
  
  Question "? 3 4 5" returns 1, so there are more crewmates than impostors among players 3, 4 and 5.
  
  Outputting "! 3 4 1 2" means that one has found all the impostors, by some miracle. There are k = 3 impostors. The players who are impostors are players 4, 1 and 2.
  
  For the second test case:
  
  Question "? 7 1 9" returns 1, so there are more crewmates than impostors among players 7, 1 and 9.
  
  Outputting "! 4 2 3 6 8" means that one has found all the impostors, by some miracle. There are k = 4 impostors. The players who are impostors are players 2, 3, 6 and 8.
solution: import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.math.BigInteger;
  import java.text.DecimalFormat;
  import java.util.*;
  import java.util.concurrent.ThreadLocalRandom;
  import java.util.stream.Collectors;
  import java.util.stream.IntStream;
  import java.util.stream.LongStream;
  
  public class TaskB {
  
      static long mod = 1000000007;
      static FastScanner scanner;
  
      static final StringBuilder result = new StringBuilder();
  
      public static void main(String[] args) {
          scanner = new FastScanner();
          int T = scanner.nextInt();
          for (int t = 0; t < T; t++) {
              solve(t + 1);
              result.append("\n");
          }
          System.out.println(result);
      }
  
      static void solve(int t) {
          int n = scanner.nextInt();
          int[] result = new int[n];
          Arrays.fill(result, -1);
  
          int[] eachThree = new int[n];
          Arrays.fill(result, -1);
          for (int i = 0; i < n; i += 3) {
              eachThree[i] = ask(i, i + 1, i + 2);
          }
  
          int firstZero = -1, firstOne = -1;
          for (int i = 0; i < n; i += 3) {
              if (eachThree[i] == 0 && firstZero == -1) {
                  firstZero = i;
              }
              if (eachThree[i] == 1 && firstOne == -1) {
                  firstOne = i;
              }
          }
          fillSix(result, eachThree, firstZero, firstOne);
          int one = -1;
          int zero = -1;
          for (int i = 0; i < n; i++) {
              if (result[i] == 0) zero = i;
              if (result[i] == 1) one = i;
          }
          for (int i = 0; i < n; i += 3) {
              if (i == firstZero || i == firstOne) {
                  continue;
              }
              fillBlock(result, i, eachThree[i], one, zero);
          }
  
          int k = 0;
          for (int i = 0; i < n; i++) {
              k += result[i] == 0 ? 1 : 0;
          }
          StringBuilder resp = new StringBuilder("! ");
          resp.append(k).append(" ");
          for (int i = 0; i < n; i++) {
              if (result[i] == 0) {
                  resp.append(i + 1).append(" ");
              }
          }
          System.out.println(resp.toString());
          System.out.flush();
      }
  
      static void fillBlock(int[] result, int idx, int blockResult, int one, int zero) {
          if (blockResult == 0) {
              int a = ask(one, idx, idx + 1);
              int b = ask(one, idx + 1, idx + 2);
              if (a == 0 && b == 0) {
                  result[idx] = result[idx + 1] = result[idx + 2] = 0;
              }
              if (a == 1 && b == 1) {
                  result[idx] = result[idx + 2] = 0;
                  result[idx + 1] = 1;
              }
              if (a == 1 && b == 0) {
                  result[idx + 1] = result[idx + 2] = 0;
                  result[idx] = 1;
              }
              if (a == 0 && b == 1) {
                  result[idx + 1] = result[idx] = 0;
                  result[idx + 2] = 1;
              }
          } else {
              int a = ask(zero, idx, idx + 1);
              int b = ask(zero, idx + 1, idx + 2);
              if (a == 1 && b == 1) {
                  result[idx] = result[idx + 1] = result[idx + 2] = 1;
              }
              if (a == 0 && b == 0) {
                  result[idx] = result[idx + 2] = 1;
                  result[idx + 1] = 0;
              }
              if (a == 0 && b == 1) {
                  result[idx + 1] = result[idx + 2] = 1;
                  result[idx] = 0;
              }
              if (a == 1 && b == 0) {
                  result[idx + 1] = result[idx] = 1;
                  result[idx + 2] = 0;
              }
          }
      }
  
      static void fillSix(int[] result, int[] eachThree, int firstZero, int firstOne) {
          int a = firstZero;
          int b = firstOne;
          if (a > b) {
              b = firstZero;
              a = firstOne;
          }
  
          int[] data = new int[]{eachThree[a], ask(a + 1, a + 2, b), ask(a + 2, b, b + 1),
                  eachThree[b]};
          int f1 = -1, f2 = -1;
          for (int i = 0; i < 3; i++) {
              if (data[i] != data[i + 1]) {
                  result[a + i] = data[i];
                  result[b + i] = data[i + 1];
                  f1 = a + i;
                  f2 = b + i;
                  break;
              }
          }
  
          for (int i = 0; i < 3; i++) {
              if (result[a + i] == -1) {
                  result[a + i] = ask(f1, f2, a + i);
              }
              if (result[b + i] == -1) {
                  result[b + i] = ask(f1, f2, b + i);
              }
          }
      }
  
      static int ask(int a, int b, int c) {
          System.out.printf("? %d %d %d", a + 1, b + 1, c + 1);
          System.out.println();
          System.out.flush();
          return scanner.nextInt();
      }
  
      static class WithIdx implements Comparable<WithIdx> {
          long val, idx;
  
          public WithIdx(long val, long idx) {
              this.val = val;
              this.idx = idx;
          }
  
          @Override
          public int compareTo(WithIdx o) {
              if (val == o.val) {
                  return Long.compare(idx, o.idx);
              }
              return Long.compare(val, o.val);
          }
      }
  
      public static class FastScanner {
          BufferedReader br;
          StringTokenizer st;
  
          public FastScanner() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
  
          String nextToken() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          String nextLine() {
              try {
                  return br.readLine();
              } catch (Exception e) {
                  e.printStackTrace();
                  throw new RuntimeException();
              }
          }
  
          int nextInt() {
              return Integer.parseInt(nextToken());
          }
  
          long nextLong() {
              return Long.parseLong(nextToken());
          }
  
          double nextDouble() {
              return Double.parseDouble(nextToken());
          }
  
          int[] nextIntArray(int n) {
              int[] res = new int[n];
              for (int i = 0; i < n; i++) res[i] = nextInt();
              return res;
          }
  
          long[] nextLongArray(int n) {
              long[] res = new long[n];
              for (int i = 0; i < n; i++) res[i] = nextLong();
              return res;
          }
  
          String[] nextStringArray(int n) {
              String[] res = new String[n];
              for (int i = 0; i < n; i++) res[i] = nextToken();
              return res;
          }
      }
  
      static class PrefixSums {
          long[] sums;
  
          public PrefixSums(long[] sums) {
              this.sums = sums;
          }
  
          public long sum(int fromInclusive, int toExclusive) {
              if (fromInclusive > toExclusive) throw new IllegalArgumentException("Wrong value");
              return sums[toExclusive] - sums[fromInclusive];
          }
  
          public static PrefixSums of(int[] ar) {
              long[] sums = new long[ar.length + 1];
              for (int i = 1; i <= ar.length; i++) {
                  sums[i] = sums[i - 1] + ar[i - 1];
              }
              return new PrefixSums(sums);
          }
  
          public static PrefixSums of(long[] ar) {
              long[] sums = new long[ar.length + 1];
              for (int i = 1; i <= ar.length; i++) {
                  sums[i] = sums[i - 1] + ar[i - 1];
              }
              return new PrefixSums(sums);
          }
      }
  
      static class ADUtils {
          static void sort(int[] ar) {
              Random rnd = ThreadLocalRandom.current();
              for (int i = ar.length - 1; i > 0; i--) {
                  int index = rnd.nextInt(i + 1);
                  // Simple swap
                  int a = ar[index];
                  ar[index] = ar[i];
                  ar[i] = a;
              }
              Arrays.sort(ar);
          }
  
          static void reverse(int[] arr) {
              int last = arr.length / 2;
              for (int i = 0; i < last; i++) {
                  int tmp = arr[i];
                  arr[i] = arr[arr.length - 1 - i];
                  arr[arr.length - 1 - i] = tmp;
              }
          }
  
          static void sort(long[] ar) {
              Random rnd = ThreadLocalRandom.current();
              for (int i = ar.length - 1; i > 0; i--) {
                  int index = rnd.nextInt(i + 1);
                  // Simple swap
                  long a = ar[index];
                  ar[index] = ar[i];
                  ar[i] = a;
              }
              Arrays.sort(ar);
          }
      }
  
      static class MathUtils {
          static long[] FIRST_PRIMES = {
                  2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
                  31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
                  73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
                  127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
                  179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
                  233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
                  283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
                  353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
                  419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
                  467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
                  547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
                  607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
                  661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
                  739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
                  811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
                  877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
                  947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013,
                  1019, 1021, 1031, 1033, 1039, 1049, 1051};
  
          static long[] primes(int to) {
              long[] all = new long[to + 1];
              long[] primes = new long[to + 1];
              all[1] = 1;
              int primesLength = 0;
              for (int i = 2; i <= to; i++) {
                  if (all[i] == 0) {
                      primes[primesLength++] = i;
                      all[i] = i;
                  }
                  for (int j = 0; j < primesLength && i * primes[j] <= to && all[i] >= primes[j];
                          j++) {
                      all[(int) (i * primes[j])] = primes[j];
                  }
              }
              return Arrays.copyOf(primes, primesLength);
          }
  
          static long modpow(long b, long e, long m) {
              long result = 1;
  
              while (e > 0) {
                  if ((e & 1) == 1) {
                      /* multiply in this bit's contribution while using modulus to keep
                       * result small */
                      result = (result * b) % m;
                  }
                  b = (b * b) % m;
                  e >>= 1;
              }
  
              return result;
          }
  
          static long submod(long x, long y, long m) {
              return (x - y + m) % m;
          }
  
          static long modInverse(long a, long m) {
              long g = gcdF(a, m);
              if (g != 1) {
                  throw new IllegalArgumentException("Inverse doesn't exist");
              } else {
                  // If a and m are relatively prime, then modulo
                  // inverse is a^(m-2) mode m
                  return modpow(a, m - 2, m);
              }
          }
  
          static public long gcdF(long a, long b) {
              while (b != 0) {
                  long na = b;
                  long nb = a % b;
                  a = na;
                  b = nb;
              }
              return a;
          }
      }
  }
  
  /*
  5
  3 2 3 8 8
  2 8 5 10 1
  
   */