#include <bits/stdc++.h>
using namespace std;
const int N = 128;
string sl = "l", sr = "r", su = "u", sd = "d";
string A, B, C, D, S, ans;
int T, k, n;
int p[N], a[2][N];
int trs(char *c) {
  int l = strlen(c), x = 0;
  for (int i = 0; i < l; i++) x = x * 10 + c[i] - '0';
  return x;
}
string operator*(string S, int k) {
  string T = "";
  while (k--) T += S;
  return T;
}
void zig() {
  int z = p[0];
  for (int i = 0; i + 1 < n; i++) p[i] = p[i + 1];
  p[n - 1] = z;
  ans += "A";
}
void zag() {
  int z = p[n - 1];
  for (int i = n - 1; i; i--) p[i] = p[i - 1];
  p[0] = z;
  ans += "B";
}
void rot() {
  swap(p[0], p[2]);
  swap(p[1], p[2]);
  ans += "S";
}
void Main() {
  cin >> k;
  n = 0;
  int len = 2 * k + 1;
  int x = 0, y = 0;
  for (int i = 0; i < len; i++) {
    char c[5];
    scanf("%s", c);
    if (c[0] == 'E')
      a[x = 0][y = i] = 0;
    else
      a[0][i] = trs(c);
  }
  for (int i = 0; i < len; i++) {
    char c[5];
    scanf("%s", c);
    if (c[0] == 'E')
      a[x = 1][y = i] = 0;
    else
      a[1][i] = trs(c);
  }
  ans = "";
  while (x || y != k) {
    if (x == 0) {
      if (y > k) ans += sl, swap(a[x][y - 1], a[x][y]), --y;
      if (y < k) ans += sr, swap(a[x][y], a[x][y + 1]), ++y;
    } else {
      if (y)
        ans += sl, swap(a[x][y - 1], a[x][y]), --y;
      else
        ans += su, swap(a[x - 1][y], a[x][y]), --x;
    }
  }
  for (int i = 0; i < len; i++)
    if (a[0][i]) p[n++] = a[0][i];
  for (int i = 0; i < len; i++)
    if (a[1][len - i - 1]) p[n++] = a[1][len - i - 1];
  for (int i = 0; i < n; i++)
    if (p[i] > len) p[i] = n - (p[i] - len) + 1;
  bool ok = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (p[i] > p[j]) ok ^= 1;
  if (ok) return puts("SURGERY FAILED"), void();
  A = sr * k + sd + sl * (len - 1) + su + sr * k;
  B = sl * k + sd + sr * (len - 1) + su + sl * k;
  C = sr * k + sd + sl * k + su;
  D = sd + sr * k + su + sl * k;
  S = string("B") * (k - 1) + "CBCADD" + string("A") * (k - 1);
  while (p[0] != 1) zag();
  for (int i = 2; i + 1 < n; i++) {
    int d = -1;
    while (p[0] != i) zig(), ++d;
    if (d & 1) {
      if (p[1] == 1)
        zag(), zag(), rot(), rot(), zig(), --d;
      else if (p[2] == 1)
        zag(), rot(), zig(), zig(), ++d;
      else
        rot(), zig(), ++d;
    }
    while (d) d -= 2, zag(), zag(), rot();
  }
  while (p[0] != 1) zag();
  ans += sr * k + sd;
  puts("SURGERY COMPLETE");
  cout << ans << '\n';
  cout << "A " << A << '\n';
  cout << "B " << B << '\n';
  cout << "C " << C << '\n';
  cout << "D " << D << '\n';
  cout << "S " << S << '\n';
  puts("DONE");
}
int main() {
  cin >> T;
  while (T--) Main();
  return 0;
}
