// editor2
#include <iostream>
using namespace std;
bool islow(string s)
{
    for(char c : s)
    {
        if(!(c>='a' && c<= 'z'))
        {
            return false;
        }
        return true;
    }
}

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(!islow(s1) || !islow(s2))
    {
        cout<<"Invalid input";
        return 0;
    }
    if(s1.length() !=s2.length())
    {
        cout<<"false";
        return 0;
    }
    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";
    }
    else
    {
        cout<<"false";
    }
    return 0;
}