#include<iostream>
#include<string>
using namespace std;
bool islowercase(string s){
    for(char c:s){
        if(c<'a'||c>'z')
        return false;
    }
    return true;
    
}
int main(){
    string s1,s2;
    cin>>s1>>s2;
    if(!islowercase(s1)||!islowercase(s2)){
        cout<<"Invalid input";
        return 0;
    }
    if(s1.lenght()!= s2.length()){
        cout<<"false";
        return 0;
    }
    string rotated=s1.substr(2)+s1.substr(0,2);
    if(rotated==s2)
         cout<<"true";
    else
         cout<<"false";
    return 0;
}