#include <iostream>
#include <stdio.h>

using namespace std;

int rawdata[] = {
  0, 1, 2, 3,
  0, 1, 2, 12,
  0, 1, 2, 10,
  0, 1, 2, 11,
  0, 1, 11, 12,
  1, 2, 10, 11,
  0, 1, 10, 11,
  0, 1, 2, 100,
  0, 1, 11, 100,
  0, 10, 11, 100,
  0, 1, 2, 101,
  0, 1, 10, 100,
  0, 100, 101, 102,
  0, 100, 101, 111,
  0, 100, 110, 111,
  1, 100, 101, 102,
  0, 100, 101, 110,
  0, 1, 101, 102,
  0, 10, 100, 101, 
  0, 1, 100, 110,
  0, 100, 200, 1,
  0, 100, 200, 201,
  0, 100, 200, 101,
  0, 100, 1, 101,
  0, 100, 101, 201,
  0, 100, 200, 300,
};

int ori[26][4][4];

void swapifnecessary(int& a, int& b) {
  if (a > b) {
    a = a+b;
    b = a-b;
    a = a-b;
  }
}

int grid[900] = {
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -1, -1, -1, -1, -2, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -2, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -1, -1, -1, -1, -1, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
  -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,

};

int pc[26] = {
  -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1,
  -1, -1, -1, -1, -1, -1
};

int print() {
  for (int y=0;y<5;y++) {
  for (int z=0;z<4;z++) {
  for (int x=0;x<9;x++) {
    int pos = x*100+y*10+z;
    if (grid[pos] == -2) cerr << "%"; else
    if (grid[pos] == -1) cerr << "-"; else
    cerr << (char)('A'+(grid[pos]/4));
  }
  cerr << " ";
  }
  cerr << "\n";
  }
  cerr << "\n";
}

long counter = 0;

void recurse(int placed) {
  if (placed == 5) {
    if (pc[10] != -1 && pc[12] != -1 && pc[15] != -1) {
      cerr << "Solution!\n";
      print();
    }
    for (int i=0;i<26;i++) {
      if (pc[i] != -1) {
        cout << (char)('A'+i);
      }
    }
    cout << "\n";
  } else if (placed < 0) {
    int piece = 4+placed;
    for (int hole=0;hole<400;hole++) {
      if (grid[hole] != -1) continue;
      for (int oi=0;oi<4;oi++) {
        // does it fit?
        bool fits = true;
        for (int cell=0;cell<4;cell++) {
          if (hole+ori[piece][oi][cell] >= 400) fits = false;
          if (!fits) break;
          if (grid[hole+ori[piece][oi][cell]] != -1) fits = false;
          if (!fits) break;
        }
        if (!fits) continue;
        // yay, fits!  put it in.
        for (int cell=0;cell<4;cell++) {
          grid[hole+ori[piece][oi][cell]] = piece*4+oi;
        }
        pc[piece] = 0;
        //recurse
        recurse(placed+1);
        // take it out
        for (int cell=0;cell<4;cell++) {
          grid[hole+ori[piece][oi][cell]] = -1;
        }
        pc[piece] = -1;
      }
    }
  } else {
    counter++;
    if(counter % 1000000 == 0) {
      cerr << counter << " trials\n";
      print();
    }
    int hole = 0;
    while (grid[hole] != -1) hole++;
    for (int piece=0;piece<26;piece++) {
      if (pc[piece] != -1) continue;
      for (int oi=0;oi<4;oi++) {
        // does it fit?
        bool fits = true;
        for (int cell=0;cell<4;cell++) {
          if (hole+ori[piece][oi][cell] >= 400) fits = false;
          if (!fits) break;
          if (grid[hole+ori[piece][oi][cell]] != -1) fits = false;
          if (!fits) break;
        }
        if (!fits) continue;
        // yay, fits!  put it in.
        for (int cell=0;cell<4;cell++) {
          grid[hole+ori[piece][oi][cell]] = piece*4+oi;
        }
        pc[piece] = 0;
        //recurse
        recurse(placed+1);
        // take it out
        for (int cell=0;cell<4;cell++) {
          grid[hole+ori[piece][oi][cell]] = -1;
        }
        pc[piece] = -1;
      }
    }
  }
}

int main () {
  for (int piece=0;piece<26;piece++) {
    int cur[4];
    for (int oi=0;oi<4;oi++) {
      // rotate the pieces
      for (int cell=0;cell<4;cell++) {
        int x = rawdata[4*piece+cell] % 10;
        int y = rawdata[4*piece+cell] / 10 % 10;
        int z = rawdata[4*piece+cell] / 100;
        switch (oi) {
          case 0: cur[cell] = x * 100 + y * 10 + z; break;
          case 1: cur[cell] = y * 100 - x * 10 + z; break;
          case 2: cur[cell] = - x * 100 - y * 10 + z; break;
          case 3: cur[cell] = - y * 100 + x * 10 + z; break;
        }
      }
      // sort the pieces
      swapifnecessary((cur[0]), (cur[1]));
      swapifnecessary((cur[0]), (cur[2]));
      swapifnecessary((cur[0]), (cur[3]));
      swapifnecessary((cur[1]), (cur[2]));
      swapifnecessary((cur[1]), (cur[3]));
      swapifnecessary((cur[2]), (cur[3]));
      // assign the pieces.
      for (int cell=3;cell>=0;cell--) {
        ori[piece][oi][cell] = cur[cell] - cur[0];
      }
    }
  }
  cerr << "calc done.\n";
  for (int piece=0;piece<26;piece++) {
    for (int oi=0;oi<4;oi++) {
      cerr << "(";
      for (int cell=0;cell<4;cell++) {
        cerr << ( cell!=0 ? "," : "" ) << ori[piece][oi][cell];
      }
      cerr << ")";
    }
    cerr << "\n";
  }
  cerr << "are pieces...\n";
  recurse(0);
}
