#include <iostream>
#include <string>
using namespace std;

int main(){
	int tbl[9] = {};
	for(int i = 0; i < 3; ++i)
	for(int j = 0; j < 3; ++j){
		int t = i * 3 + j;
		if(i != 0){
			int u = t - 3;
			tbl[t] |= 1 << u;
			tbl[u] |= 1 << t;
		}
		if(j != 0){
			int u = t - 1;
			tbl[t] |= 1 << u;
			tbl[u] |= 1 << t;
		}
	}
	
	string s;
	while(cin >> s){
		bool ok = true;
		for(int i = 1; i < s.size(); ++i){
			if(!(tbl[s[i - 1] - 'A'] >> (s[i] - 'A') & 1)){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << s << '\n';
		}
	}
}