#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

const int dy[]={-1,0,1,0};
const int dx[]={0,-1,0,1};

int main(){
    rep(_,1000){
        string str;
        cin>>str;
        bool endFlag=false;
        rep(i,str.size()-1){
            int y=(str[i]-'A')/3;
            int x=(str[i]-'A')%3;
            bool flag=false;
            rep(k,4){
                int ty=y+dy[k];
                int tx=x+dx[k];
                if(ty<0||ty>=3||tx<0||tx>=3)continue;
                if(ty*3+tx==str[i+1]-'A')flag=true;
            }
            if(!flag){
                endFlag=true;
                break;
            }
        }
        if(endFlag)continue;
        cout<<str<<endl;
    }
    return 0;
}