#include<iostream>
#include<string>
#include<cctype>
using namespace std;
bool isValid(string s){
    for(char c:s)if(!islower(c))return false;
    return !s.empty();
}
int main(){
    string s1,s2;
    if(!(cin>>s1>>s2))return 0;
    if (!isValid(s1)||!isVaild(s2)){
        cout<<"Invalid input"<<endl;
    }else if{(s1.length()!=s2.length()||s1.length()<2){
        cout<<"false"<<endl;
    }else{
        int n=s1.length();
        string left =s1.substr(2)+s1.substr(0,2);
        string right =s1.substr(n-2)+s1.substr(0,n-2);
        if(s2==left||s2==right)cout<<"true"<<endl;
        else cout<<"false"<<endl;
        
    }
    }
    return 0;
}