#include <bits/stdc++.h>
using namespace std;
int cnt[10];
bool valid(string a, string b) {
  int N = a.length() / 2;
  int i;
  for ((i) = 0; (i) < (int)(4); (i)++) cnt[i] = 0;
  for ((i) = 0; (i) < (int)(N); (i)++) {
    int p = (a[2 * i] - '0') * 2 + (a[2 * i + 1] - '0') * 1;
    cnt[p]++;
    p = (b[2 * i] - '0') * 1 + (b[2 * i + 1] - '0') * 2;
    cnt[p]--;
  }
  for ((i) = 0; (i) < (int)(4); (i)++)
    if (cnt[i] != 0) return false;
  return true;
}
vector<int> ans;
void main3(string a, string b) {
  int i, j;
  int N = a.length() / 2;
  for ((i) = 0; (i) < (int)(N); (i)++) {
    char p = b[2 * (N - 1 - i)], q = b[2 * (N - 1 - i) + 1];
    for (j = i; j < N; j++)
      if (a[2 * j] == q && a[2 * j + 1] == p) break;
    if (j > 0) ans.push_back(2 * j);
    ans.push_back(2 * (j + 1));
    reverse(a.begin(), a.begin() + (2 * j));
    reverse(a.begin(), a.begin() + (2 * j + 2));
  }
}
void print(void) {
  int i;
  int sz = ans.size();
  cout << sz << endl;
  for ((i) = 0; (i) < (int)(sz); (i)++) cout << ans[i] << ' ';
  cout << endl;
}
void main2(string a, string b) {
  int N = a.length() / 2;
  int i;
  ans.clear();
  if (valid(a, b)) {
    main3(a, b);
    print();
    return;
  }
  for (i = 1; i <= N; i++) {
    string a2 = a;
    reverse(a2.begin(), a2.begin() + (2 * i));
    if (valid(a2, b)) {
      ans.push_back(2 * i);
      main3(a2, b);
      print();
      return;
    }
  }
  for (i = 1; i <= N; i++) {
    string b2 = b;
    reverse(b2.begin(), b2.begin() + (2 * i));
    if (valid(a, b2)) {
      main3(a, b2);
      ans.push_back(2 * i);
      print();
      return;
    }
  }
  cout << -1 << endl;
}
int main(void) {
  int T, t;
  cin >> T;
  for ((t) = 0; (t) < (int)(T); (t)++) {
    string a, b;
    cin >> a >> b;
    main2(a, b);
  }
  return 0;
}
