// AOJ 1516: Nasty Boys
// 2017.9.27 bal4u@uu

#include <stdio.h>

int rr[9] = { 0,0,0,1,1,1,2,2,2 };
int cc[9] = { 0,1,2,0,1,2,0,1,2 };

int main()
{
	int i, r, c, r2, c2, f;
	char buf[20], *p;

	for (i = 0; i < 1000; i++) {
		scanf("%s", p = buf);
		r = rr[*p-'A'], c = cc[*p-'A'], p++; f = 1;
		while (*p && f) {
			f = 0;
			r2 = rr[*p-'A'], c2 = cc[*p-'A'], p++;
			if      (r2 == r) { if (c2 == c+1 || c2 == c-1) f = 1; }
			else if (c2 == c) { if (r2 == r+1 || r2 == r-1) f = 1; }
			r = r2, c = c2;
		}
		if (f) puts(buf);
	}
	return 0;
}