#include <cstdlib>
#include <iostream>
#include <set>
using namespace std;

pair<int, int> xy(char c){
  const int m = c - 'A';
  return make_pair(m % 3, m / 3);
}

int main(){
  string s;

  while(cin >> s){
    const int n = s.length();
    pair<int, int> now = xy(s[0]);

    bool ok = true;
    for(int i = 1; i < n; i++){
      const pair<int, int> next = xy(s[i]);
      if(std::abs(next.first - now.first) +
         std::abs(next.second - now.second) != 1)
        ok = false;
      now = next;
    }

    if(ok) cout << s << endl;
  }

  return 0;
}