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

set<string> adj = {"AB","AD","BA","BC","BE","CB","CF","DA","DE","DG","EB","ED","EF","EH","FC","FE","FI","GD","GH","HE","HG","HI","IF","IH"};

int main() {
    string s;
    for (int i=0; i<1000; ++i) {
        cin >> s;
        bool ok = true;
        for (int i=1; i<(int)s.size(); ++i) {
            if ( ! adj.count(s.substr(i-1, 2))) {
                ok = false;
                break;
            }
        }
        if (ok) cout << s << endl;
    }
    return 0;
}