function q(a,b,c,d,e,f,g,h:char):boolean;
begin
if ((e=a) and (f=b) and (g=c) and (h=d)) or
.............
{всевозможные перестановки граней 1-го тетраэдра}
.............
or ((e=d) and (f=a) and (g=c) and (h=b))
then q:=true else q:=false;
end;
var a,b,c,d,e,f,g,h:char; x,y:string[4];
begin
readln(x);
readln(y);
a:=x[1]; b:=x[2]; c:=x[3]; d:=x[4];
e:=y[1]; f:=y[2]; g:=y[3]; h:=y[4];
if ((q(a,b,c,d,e,f,g,h))=true) or
((q(a,b,c,d,e,g,h,f))=true) or
................
{всевозможные перестановки граней 2-го тетраэдра}
................
((q(a,b,c,d,h,f,e,g))=true) or
((q(a,b,c,d,h,e,g,f))=true)
then writeln('equal')
else writeln('different');
end.