#include <bits/stdc++.h>
using namespace std;
int K;
vector<int> A;
vector<vector<int>> table;
string finalSequence;
void rotateForward() {
  if (!finalSequence.empty() && finalSequence.back() == 'B')
    finalSequence.pop_back();
  else
    finalSequence += "F";
  for (int i = 4 * K; i > 0; --i) {
    swap(A[i - 1], A[i]);
  }
}
void rotateBackward() {
  if (!finalSequence.empty() && finalSequence.back() == 'F')
    finalSequence.pop_back();
  else
    finalSequence += "B";
  for (int i = 1; i <= 4 * K; ++i) {
    swap(A[i - 1], A[i]);
  }
}
void simpleJump() {
  finalSequence += "JFF";
  for (int i = 1; i <= 2; ++i) {
    swap(A[i - 1], A[i]);
  }
}
void customJump(int idx) {
  for (int i = 0; i < idx; ++i) rotateBackward();
  simpleJump();
  while (A[0] != 1) rotateForward();
}
void readFromInput() {
  cin >> K;
  finalSequence = "";
  table.assign(2, vector<int>(2 * K + 1));
  for (auto &vec : table)
    for (auto &i : vec) {
      string str;
      cin >> str;
      if (str == "E")
        i = 0;
      else
        i = stoi(str);
    }
}
void backToCorner() {
  for (int row = 0; row < 2; ++row) {
    for (int col = 0; col < 2 * K; ++col) {
      if (table[row][col] == 0) {
        finalSequence += 'r';
        swap(table[row][col], table[row][col + 1]);
      }
    }
  }
  if (table[0][2 * K] == 0) {
    finalSequence += 'd';
    swap(table[0][2 * K], table[1][2 * K]);
  }
}
void relabel() {
  for (auto &vec : table)
    for (int &i : vec) {
      if (i >= 2 * K + 2)
        i = 4 * K + 2 - i;
      else if (i >= 1)
        i += 2 * K;
    }
}
void convertToA() {
  A.resize(4 * K + 1);
  for (int i = 0; i <= 2 * K; ++i) {
    A[2 * K + i] = table[0][i];
  }
  for (int i = 0; i < 2 * K; ++i) {
    A[2 * K - 1 - i] = table[1][i];
  }
  assert(table[1][2 * K] == 0);
}
string forwardDefinition() {
  return "u" + string(2 * K, 'l') + "d" + string(2 * K, 'r');
}
string backwardDefinition() {
  return string(2 * K, 'l') + "u" + string(2 * K, 'r') + "d";
}
string jumpKDefinition() {
  return string(K + 1, 'B') + (string(K, 'l') + "u" + string(K, 'r') + "d") +
         string(K + 1, 'F');
}
string jumpDefinition() {
  string def = "";
  def += "B";
  def += jumpKDefinition();
  def += jumpKDefinition();
  def += "F";
  for (int i = 0; i < K * 2; ++i) def += jumpKDefinition();
  def += "B";
  for (int i = 0; i < K * 2; ++i) def += jumpKDefinition();
  def += "F";
  assert(def.back() == 'F');
  def.pop_back();
  assert(def.back() == 'F');
  def.pop_back();
  return def;
}
void trim() {
  string copySequence = finalSequence + "$";
  finalSequence = "";
  char curChar = '?';
  int curCount = 0;
  for (char ch : copySequence) {
    if (curChar == ch) {
      ++curCount;
      if (curCount == 10) {
        if (ch == 'F')
          finalSequence += "X", curCount = 0;
        else if (ch == 'B')
          finalSequence += "Y", curCount = 0;
        else if (ch == 'J')
          finalSequence += "Z", curCount = 0;
      }
    } else {
      finalSequence += string(curCount, curChar);
      curChar = ch;
      curCount = 1;
    }
  }
}
void outputSuccess() {
  trim();
  cout << "SURGERY COMPLETE" << '\n';
  cout << finalSequence << '\n';
  cout << "F " << forwardDefinition() << '\n';
  cout << "B " << backwardDefinition() << '\n';
  cout << "J " << jumpDefinition() << '\n';
  cout << "X FFFFFFFFFF" << '\n';
  cout << "Y BBBBBBBBBB" << '\n';
  cout << "Z JJJJJJJJJJ" << '\n';
  cout << "DONE" << '\n';
}
void outputFailure() { cout << "SURGERY FAILED" << '\n'; }
void log() {
  cout << "--------------------------------" << endl;
  cout << "A = ";
  for (int x : A) cout << x << ' ';
  cout << endl;
  return;
  cout << "table: " << endl;
  for (int i = 2 * K; i <= 4 * K; ++i) {
    cout << A[i] << ' ';
  }
  cout << '\n';
  for (int i = 2 * K - 1; i >= 0; --i) {
    cout << A[i] << ' ';
  }
  cout << 'E';
  cout << '\n';
  cout << "current sequence = " << finalSequence << endl;
  cout << "--------------------------------" << endl;
  cout << endl;
}
void solve() {
  readFromInput();
  backToCorner();
  relabel();
  convertToA();
  while (A[0] != 1) rotateForward();
  for (int noFixed = 1; noFixed <= 4 * K - 2; ++noFixed) {
    int nextValue = noFixed + 1;
    int curPos = (int)(find(A.begin(), A.end(), nextValue) - A.begin());
    while (curPos < noFixed || curPos > noFixed + 2) {
      customJump(curPos);
      curPos = (int)(find(A.begin(), A.end(), nextValue) - A.begin());
    }
    while (A[noFixed] != nextValue) {
      customJump(noFixed);
    }
  }
  bool isSorted = is_sorted(A.begin(), A.end());
  if (isSorted) {
    outputSuccess();
  } else {
    outputFailure();
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tests;
  cin >> tests;
  while (tests--) {
    solve();
  }
  return 0;
}
