#include <stdio.h>
#include <string.h>
#define a 0
#define b 1
#define c 2
#define d 3
#define e 4
#define f 5
#define g 6
#define h 7
#define i 8

int main(void) {
	int status[9][9];
	int n, I, J;
	char s[1000];
	char ch;
	int flag = 0;
	status[a][0] = 2;
	status[a][1] = b;
	status[a][2] = d;
	status[b][0] = 3;
	status[b][1] = a;
	status[b][2] = c;
	status[b][3] = e;
	status[c][0] = 2;
	status[c][1] = b;
	status[c][2] = f;
	status[d][0] = 3;
	status[d][1] = a;
	status[d][2] = e;
	status[d][3] = g;
	status[e][0] = 4;
	status[e][1] = b;
	status[e][2] = d;
	status[e][3] = f;
	status[e][4] = h;
	status[f][0] = 3;
	status[f][1] = c;
	status[f][2] = e;
	status[f][3] = i;
	status[g][0] = 2;
	status[g][1] = d;
	status[g][2] = h;
	status[h][0] = 3;
	status[h][1] = g;
	status[h][2] = e;
	status[h][3] = i;
	status[i][0] = 2;
	status[i][1] = f;
	status[i][2] = h;

	n = 1000;
	while (n--) {
		flag = 1;
		scanf("%s", s);
		ch = s[0];
		
		for (I = 1; strlen(s) >=2 &&I < strlen(s); I++) {
			for (J = 1; J <= status[ch - 'A'][0]; J++) {
				if (status[ch - 'A'][J] == s[I]-'A') break;
			}
			if (J == status[ch - 'A'][0] + 1) {
				flag = 0; break;
			}
			if (I != strlen(s) - 1)ch = s[I];
		}
		if (flag == 1) printf("%s\n", s);
	}



	return 0;
}