#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
namespace input {
template <class T>
void re(complex<T>& x);
template <class T1, class T2>
void re(pair<T1, T2>& p);
template <class T>
void re(vector<T>& a);
template <class T, size_t SZ>
void re(array<T, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(double& x) {
  string t;
  re(t);
  x = stod(t);
}
void re(long double& x) {
  string t;
  re(t);
  x = stold(t);
}
template <class T, class... Ts>
void re(T& t, Ts&... ts) {
  re(t);
  re(ts...);
}
template <class T>
void re(complex<T>& x) {
  T a, b;
  re(a, b);
  x = cd(a, b);
}
template <class T1, class T2>
void re(pair<T1, T2>& p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T>& a) {
  for (int i = (0); i < ((int)a.size()); ++i) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ>& a) {
  for (int i = (0); i < (SZ); ++i) re(a[i]);
}
}  // namespace input
using namespace input;
namespace output {
void pr(int x) { cout << x; }
void pr(long x) { cout << x; }
void pr(long long x) { cout << x; }
void pr(unsigned x) { cout << x; }
void pr(unsigned long x) { cout << x; }
void pr(unsigned long long x) { cout << x; }
void pr(float x) { cout << x; }
void pr(double x) { cout << x; }
void pr(long double x) { cout << x; }
void pr(char x) { cout << x; }
void pr(const char* x) { cout << x; }
void pr(const string& x) { cout << x; }
void pr(bool x) { pr(x ? "true" : "false"); }
template <class T>
void pr(const complex<T>& x) {
  cout << x;
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x);
template <class T>
void pr(const T& x);
template <class T, class... Ts>
void pr(const T& t, const Ts&... ts) {
  pr(t);
  pr(ts...);
}
template <class T1, class T2>
void pr(const pair<T1, T2>& x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T>
void pr(const T& x) {
  pr("{");
  bool fst = 1;
  for (const auto& a : x) pr(!fst ? ", " : "", a), fst = 0;
  pr("}");
}
void ps() { pr("\n"); }
template <class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
  pr(t);
  if (sizeof...(ts)) pr(" ");
  ps(ts...);
}
void pc() { pr("]\n"); }
template <class T, class... Ts>
void pc(const T& t, const Ts&... ts) {
  pr(t);
  if (sizeof...(ts)) pr(", ");
  pc(ts...);
}
}  // namespace output
using namespace output;
namespace io {
void setIn(string second) { freopen(second.c_str(), "r", stdin); }
void setOut(string second) { freopen(second.c_str(), "w", stdout); }
void setIO(string second = "") {
  cin.sync_with_stdio(0);
  cin.tie(0);
  if ((int)second.size()) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
}  // namespace io
using namespace io;
typedef decay<decltype(MOD)>::type T;
struct mi {
  T val;
  explicit operator T() const { return val; }
  mi() { val = 0; }
  mi(const long long& v) {
    val = (-MOD <= v && v <= MOD) ? v : v % MOD;
    if (val < 0) val += MOD;
  }
  friend void pr(const mi& a) { pr(a.val); }
  friend void re(mi& a) {
    long long x;
    re(x);
    a = mi(x);
  }
  friend bool operator==(const mi& a, const mi& b) { return a.val == b.val; }
  friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
  friend bool operator<(const mi& a, const mi& b) { return a.val < b.val; }
  mi operator-() const { return mi(-val); }
  mi& operator+=(const mi& m) {
    if ((val += m.val) >= MOD) val -= MOD;
    return *this;
  }
  mi& operator-=(const mi& m) {
    if ((val -= m.val) < 0) val += MOD;
    return *this;
  }
  mi& operator*=(const mi& m) {
    val = (long long)val * m.val % MOD;
    return *this;
  }
  friend mi pow(mi a, long long p) {
    mi ans = 1;
    assert(p >= 0);
    for (; p; p /= 2, a *= a)
      if (p & 1) ans *= a;
    return ans;
  }
  friend mi inv(const mi& a) {
    assert(a != 0);
    return pow(a, MOD - 2);
  }
  mi& operator/=(const mi& m) { return (*this) *= inv(m); }
  friend mi operator+(mi a, const mi& b) { return a += b; }
  friend mi operator-(mi a, const mi& b) { return a -= b; }
  friend mi operator*(mi a, const mi& b) { return a *= b; }
  friend mi operator/(mi a, const mi& b) { return a /= b; }
};
int k, R, g[2][31];
pair<int, int> pos;
string ans;
void prin() {
  for (int i = (0); i < (2); ++i) {
    for (int j = (0); j < (R); ++j) pr(g[i][j], ' ');
    ps();
  }
  ps("-------");
}
void upMov() {
  assert(pos.first == 1 && pos.second % k == 0);
  swap(g[pos.first][pos.second], g[pos.first - 1][pos.second]);
  pos.first--;
}
void up() {
  upMov();
  ans += 'u';
}
void downMov() {
  assert(pos.first == 0 && pos.second % k == 0);
  swap(g[pos.first][pos.second], g[pos.first + 1][pos.second]);
  pos.first++;
}
void down() {
  downMov();
  ans += 'd';
}
void leftMov() {
  assert(pos.second);
  swap(g[pos.first][pos.second], g[pos.first][pos.second - 1]);
  pos.second--;
}
void left() {
  leftMov();
  ans += 'l';
}
void rightMov() {
  assert(pos.second < R - 1);
  swap(g[pos.first][pos.second], g[pos.first][pos.second + 1]);
  pos.second++;
}
void right() {
  rightMov();
  ans += 'r';
}
void gor() {
  if (pos == make_pair(1, 0))
    up();
  else if (pos == make_pair(0, R - 1))
    down();
  else if (pos.first == 1)
    left();
  else
    right();
}
void ROT() {
  ans += 'B';
  for (int i = (0); i < (k); ++i) leftMov();
  upMov();
  for (int i = (0); i < (R - 1); ++i) rightMov();
  downMov();
  for (int i = (0); i < (k); ++i) leftMov();
}
void ROT2() {
  ans += 'C';
  for (int i = (0); i < (k); ++i) leftMov();
  downMov();
  for (int i = (0); i < (R - 1); ++i) rightMov();
  upMov();
  for (int i = (0); i < (k); ++i) leftMov();
}
void RIGHT(int x) {
  while (pos != make_pair(1, k)) gor();
  while (g[0][k] != x) ROT();
  up();
}
void LEFT(int x) {
  while (pos != make_pair(0, k)) gor();
  while (g[1][k] != x) ROT2();
  down();
}
void rmap() {
  for (int i = (0); i < (2); ++i)
    for (int j = (0); j < (R); ++j)
      if (g[i][j] > R) g[i][j] = 3 * R - g[i][j];
}
string tmp, rot, rot2;
bool done() {
  for (int i = (0); i < (R); ++i)
    if (g[0][i] != i + 1) return 0;
  int cnt = R;
  for (int i = (R)-1; i >= (0); --i)
    if (i != k) {
      cnt++;
      if (g[1][i] != cnt) return 0;
    }
  return 1;
}
void solve() {
  re(k);
  R = 2 * k + 1;
  ans = tmp = rot = rot2 = "";
  int cnt = 0;
  for (int j = (0); j < (R); ++j) g[0][j] = ++cnt;
  for (int j = (R)-1; j >= (0); --j)
    if (j != k) g[1][j] = ++cnt;
  pos = {1, k};
  RIGHT(1);
  RIGHT(1);
  RIGHT(2);
  LEFT(3);
  LEFT(2);
  LEFT(3);
  while (g[0][0] != 2 || pos != make_pair(1, k)) gor();
  swap(tmp, ans);
  for (int i = (0); i < (2); ++i) {
    for (int j = (0); j < (R); ++j) {
      string second;
      re(second);
      if (second == "E") {
        g[i][j] = 0;
        pos = {i, j};
      } else
        g[i][j] = stoi(second);
    }
  }
  while (pos.second < R - 1) right();
  if (pos.first == 0) down();
  int inv = 0;
  for (int i = (0); i < (2 * R - 1); ++i)
    for (int j = (i + 1); j < (2 * R - 1); ++j) {
      if (g[i / R][i % R] > g[j / R][j % R]) inv++;
    }
  if (inv & 1) {
    ps("SURGERY FAILED");
    return;
  }
  while (pos.second > k) left();
  rmap();
  for (int i = (0); i < (k); ++i) rot += 'l';
  rot += 'u';
  for (int i = (0); i < (R - 1); ++i) rot += 'r';
  rot += 'd';
  for (int i = (0); i < (k); ++i) rot += 'l';
  rot2 = rot;
  for (auto& t : rot2) {
    if (t == 'u')
      t = 'd';
    else if (t == 'd')
      t = 'u';
  }
  while (!done()) {
    ROT();
    if (g[0][0] != 2 * R - 1 && g[0][1] != 2 * R - 1 && g[0][2] != 2 * R - 1) {
      while (g[0][0] > min(g[0][1], g[0][2])) {
        swap(g[0][0], g[0][1]);
        swap(g[0][1], g[0][2]);
        ans += 'A';
      }
    }
  }
  rmap();
  while (pos.second < R - 1) right();
  ps("SURGERY COMPLETE");
  ps(ans);
  ps("A", tmp);
  ps("B", rot);
  ps("C", rot2);
  ps("DONE");
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int t;
  re(t);
  for (int i = (0); i < (t); ++i) solve();
}
