import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	auto path = new bool[][]('I'+1, 'I'+1);
	foreach (i; 'A'..'I'+1) {
		if ((i - 'A') % 3) path[i][i-1] = 1;
		if ((i - 'A') % 3 != 2) path[i][i+1] = 1;
		if ((i - 'C') > 0) path[i][i-3] = 1;
		if ((i - 'G') < 0) path[i][i+3] = 1;
	}
	foreach (line; stdin.byLine) {
		auto str = line.chomp;
		char pre = str[0];
		bool f;
		foreach (c; str[1..$]) {
			if (!path[pre][c]) {
				f = 1;
				break;
			}
			pre = c;
		} 
		if (!f) str.writeln;
	}
}