#include <bits/stdc++.h>
using namespace std;
const int N = 128;
string operator*(string a, int t) {
  string b = "";
  for (int i = 0; i < t; i++) b += a;
  return b;
}
ostream& operator<<(ostream& os, vector<int> p) {
  for (auto x : p) os << x << " ";
  os << '\n';
  return os;
}
string sl("l"), sr("r"), su("u"), sd("d");
int T, k, L, n;
int x, y;
vector<int> grid[2];
vector<int> perm;
void solve() {
  cin >> k;
  L = 2 * k + 1;
  n = 4 * k + 1;
  grid[0].resize(L);
  grid[1].resize(L);
  string _;
  for (int i = 0; i < L; i++) {
    cin >> _;
    if (_[0] == 'E') {
      grid[0][i] = -1;
      x = 0, y = i;
    } else {
      grid[0][i] = stoi(_);
    }
  }
  for (int i = 0; i < L; i++) {
    cin >> _;
    if (_[0] == 'E') {
      grid[1][i] = -1;
      x = 1, y = i;
    } else {
      grid[1][i] = stoi(_);
    }
  }
  string ans = "";
  while (x != 0 || y != k) {
    if (x == 0) {
      if (y < k) {
        ans += 'r';
        swap(grid[x][y], grid[x][y + 1]);
        y++;
      } else {
        ans += 'l';
        swap(grid[x][y], grid[x][y - 1]);
        y--;
      }
    } else {
      if (!y) {
        ans += 'u';
        swap(grid[x][y], grid[x - 1][y]);
        x--;
      } else {
        ans += 'l';
        swap(grid[x][y], grid[x][y - 1]);
        y--;
      }
    }
  }
  perm.clear();
  reverse(grid[1].begin(), grid[1].end());
  for (auto x : grid[0])
    if (x > 0) perm.push_back(x);
  for (auto x : grid[1])
    if (x > 0) perm.push_back(x);
  for (auto& x : perm)
    if (x > L) x = n - (x - L) + 1;
  int inv = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (perm[i] > perm[j]) {
        inv ^= 1;
      }
    }
  }
  if (inv) {
    cout << ("SURGERY FAILED") << '\n';
    return;
  }
  auto rotateL = [&]() {
    rotate(perm.begin(), perm.begin() + 1, perm.end());
    ans += "A";
  };
  auto rotateR = [&]() {
    rotate(perm.begin(), perm.end() - 1, perm.end());
    ans += "B";
  };
  auto shift3 = [&]() {
    swap(perm[0], perm[2]);
    swap(perm[1], perm[2]);
    ans += "S";
  };
  string A = sr * k + sd + sl * (L - 1) + su + sr * k;
  string B = sl * k + sd + sr * (L - 1) + su + sl * k;
  string C = sr * k + sd + sl * k + su;
  string D = sd + sr * k + su + sl * k;
  string S = string("B") * (k - 1) + "CBCADD" + string("A") * (k - 1);
  while (perm[0] != 1) rotateR();
  for (int i = 2; i <= n - 2; i++) {
    int d = -1;
    while (perm[0] != i) d++, rotateL();
    if (d & 1) {
      if (perm[1] == 1) {
        rotateR(), rotateR();
        shift3(), shift3();
        d--;
        rotateL();
      } else if (perm[2] == 1) {
        rotateR();
        shift3();
        d++;
        rotateL();
        rotateL();
      } else {
        shift3();
        rotateL();
        d++;
      }
    }
    while (d) {
      rotateR(), rotateR();
      shift3();
      d -= 2;
    }
  }
  while (perm[0] != 1) rotateR();
  ans += sr * k + sd;
  cout << "SURGERY COMPLETE\n";
  cout << ans << '\n';
  cout << "A " << A << '\n';
  cout << "B " << B << '\n';
  cout << "C " << C << '\n';
  cout << "D " << D << '\n';
  cout << "S " << S << '\n';
  cout << "DONE\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
