This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.

There are two binary strings a and b of length n (a binary string is a string consisting of symbols 0 and 1). In an operation, you select a prefix of a, and simultaneously invert the bits in the prefix (0 changes to 1 and 1 changes to 0) and reverse the order of the bits in the prefix.

For example, if a=001011 and you select the prefix of length 3, it becomes 011011. Then if you select the entire string, it becomes 001001.

Your task is to transform the string a into b in at most 3n operations. It can be proved that it is always possible.

Input

The first line contains a single integer t (1≤ t≤ 1000) — the number of test cases. Next 3t lines contain descriptions of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 1000) — the length of the binary strings.

The next two lines contain two binary strings a and b of length n.

It is guaranteed that the sum of n across all test cases does not exceed 1000.

Output

For each test case, output an integer k (0≤ k≤ 3n), followed by k integers p_1,…,p_k (1≤ p_i≤ n). Here k is the number of operations you use and p_i is the length of the prefix you flip in the i-th operation.

Example

Input


5
2
01
10
5
01011
11100
2
01
01
10
0110011011
1000110100
1
0
1


Output


3 1 2 1
6 5 2 5 3 1 2
0
9 4 1 2 10 4 1 2 1 5
1 1

Note

In the first test case, we have 01→ 11→ 00→ 10.

In the second test case, we have 01011→ 00101→ 11101→ 01000→ 10100→ 00100→ 11100.

In the third test case, the strings are already the same. Another solution is to flip the prefix of length 2, which will leave a unchanged.
#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const long long INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
  T X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
const int MAXN = 100005;
const int MAXV = 200001;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char A[MAXN], B[MAXN];
mt19937 mt(19270817);
struct FHQ_Treap {
  struct Node {
    int v, p, sz, ch[2];
    bool flip, f2;
    Node() {}
    Node(int v) : v(v), p(mt()), sz(1), flip(false), f2(false) {
      ch[0] = ch[1] = 0;
    }
  };
  Node nodes[MAXN];
  int tot, root, x, y, z;
  int newNode(int v) {
    nodes[++tot] = Node(v);
    return tot;
  }
  int push_up(int p) {
    nodes[p].sz = nodes[nodes[p].ch[0]].sz + nodes[nodes[p].ch[1]].sz + 1;
    return p;
  }
  void push_down(int p) {
    if (!nodes[p].flip && !nodes[p].f2) return;
    if (nodes[p].flip) {
      swap(nodes[p].ch[0], nodes[p].ch[1]);
      nodes[nodes[p].ch[0]].flip ^= true, nodes[nodes[p].ch[1]].flip ^= true;
      nodes[p].flip = false;
    }
    if (nodes[p].f2) {
      nodes[p].v ^= true;
      nodes[nodes[p].ch[0]].f2 ^= true, nodes[nodes[p].ch[1]].f2 ^= true;
      nodes[p].f2 = false;
    }
  }
  int rkk(int p) { return nodes[nodes[p].ch[0]].sz + 1; }
  void split(int p, int val, int& x, int& y) {
    if (!p) return (void)(x = y = 0);
    push_down(p);
    int rk = rkk(p);
    if (rk <= val) {
      x = p, split(nodes[p].ch[1], val - rk, nodes[p].ch[1], y);
    } else {
      y = p, split(nodes[p].ch[0], val, x, nodes[p].ch[0]);
    }
    push_up(p);
  }
  int merge(int x, int y) {
    if (!x || !y) return x + y;
    if (nodes[x].p > nodes[y].p) {
      push_down(x);
      nodes[x].ch[1] = merge(nodes[x].ch[1], y);
      return push_up(x);
    } else {
      push_down(y);
      nodes[y].ch[0] = merge(x, nodes[y].ch[0]);
      return push_up(y);
    }
  }
  void flip(int l, int r) {
    split(root, l - 1, x, y);
    split(y, r - l + 1, y, z);
    nodes[y].flip ^= true;
    root = merge(merge(x, y), z);
  }
  void rev(int l, int r) {
    split(root, l - 1, x, y);
    split(y, r - l + 1, y, z);
    nodes[y].f2 ^= true;
    root = merge(merge(x, y), z);
  }
  int get(int k) {
    split(root, k - 1, x, y);
    split(y, 1, y, z);
    int r = nodes[y].v ^ nodes[y].f2;
    root = merge(merge(x, y), z);
    return r;
  }
  void _dfs(int p) {
    if (!p) return;
    push_down(p);
    _dfs(nodes[p].ch[0]);
    printf("%d ", nodes[p].v);
    _dfs(nodes[p].ch[1]);
  }
  void print() { _dfs(root); }
  void insert(int val) { root = merge(root, newNode(val)); }
};
FHQ_Treap treap;
void solve() {
  scanf("%d", &n);
  scanf("%s", A);
  scanf("%s", B);
  treap.tot = 0;
  treap.root = 0;
  if (n == 1) {
    printf("%d ", (A[0] == B[0]) ? 0 : 1);
    if (A[0] != B[0]) printf("1\n");
    return;
  }
  vector<int> F;
  for (int i = n - 1; i >= 0; i--) A[i] -= '0';
  for (int i = n - 1; i >= 0; i--) B[i] -= '0';
  for (int i = 0; i < n; i++) {
    treap.insert(A[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (B[i] == treap.get(i + 1)) continue;
    if (B[i] == treap.get(1)) {
      F.push_back(0);
      treap.rev(1, 1);
    }
    F.push_back(i);
    treap.rev(1, i + 1);
    treap.flip(1, i + 1);
  }
  printf("%d ", F.size());
  for (auto f : F) {
    printf("%d ", f + 1);
  }
  printf("\n");
}
int main() {
  int T = read<int>();
  while (T--) {
    solve();
  }
  return 0;
}
