var obj={};
var abc="AB,AD,BA,BE,BC,CB,CF,DA,DE,DG,EB,ED,EH,EF,FC,FE,FI,GD,GH,HE,HG,HI,IF,IH".split(",");
abc.forEach(function(v){obj[v]=true;});
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
for(var I=0;I<1000;I++){
   var arr=Arr[I].split("");
   var x=arr[0];
   var flag=true;
   for(var i=1;i<arr.length;i++){
      if(obj.hasOwnProperty(x+arr[i])){
         x=arr[i];
      }else {
         flag=false;
         break;
      }
   }
   if(flag)console.log(Arr[I]);
}