#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
while(t1>-1&&t2>-1)
    {
     if(s1[t1]=='1'&&s2[t2]=='1')
    s1[t1]=s2[t2]='0';
    t1--;
    t2--;
    }
while(true)
{
    if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            s1[n1-m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
            s2[n2-m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
#include<math.h>
using namespace std;
  double q=(sqrt(5)+1)/2;
     double getDValue(string s){
        double value=0;
        for(int i=0;i<s.length();++i)
        {
            if(s[i]=='1')
                value+=pow(q, s.length()-1-i);
        }
        return value;
    }
int main(){
    string s1,s2;
    cin>>s1>>s2;
     double a=getDValue(s1),b=getDValue(s2);
        if(a==b)
            cout<<"=";
        else if(a<b)
             cout<<"<";
        else
            cout<<">";
}


#include<iostream>
#include<math.h>
using namespace std;
  double q=(sqrt(5)+1)/2;
     double getDValue(string s){
        double value=0;
        for(int i=0;i<s.length();++i)
        {
            if(s[i]=='1')
                value+=pow(q, s.length()-1-i);
        }
        return value;
    }
int main(){
    string s1,s2;
    cin>>s1>>s2;
     double a=getDValue(s1),b=getDValue(s2);
     int e =int(a*10000),f=int (b*10000);
     if(e%10>4)
       {
         e+=10;
         e/=10;
       }
     if(f%10>4)
     {
         f+=10;
         f/=10;
     }
     a=e/1000;
     b=f/1000;
        if(a==b)
            cout<<"=";
        else if(a<b)
             cout<<"<";
        else
            cout<<">";
}


#include<iostream>
#include<math.h>
using namespace std;
  double q=(sqrt(5)+1)/2;
     double getDValue(string s){
        double value=0;
        for(int i=0;i<s.length();++i)
        {
            if(s[i]=='1')
                value+=pow(q, s.length()-1-i);
        }
        return value;
    }
int main(){
    string s1,s2;
    cin>>s1>>s2;
     double a=getDValue(s1),b=getDValue(s2);
     int e =int(a*1000),f=int (b*1000);
     a=e/1000;
     b=f/1000;
        if(a==b)
            cout<<"=";
        else if(a<b)
             cout<<"<";
        else
            cout<<">";
}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1'&&i>-1)
            {
                str=str.substr(i+1);
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1'&&i+1>-1)
        {
            str=str.substr(i+2);
            return (isThere(str,0));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
while(t1>-1&&t2>-1)
    {
     if(s1[t1]=='1'&&s2[t2]=='1')
    s1[t1]=s2[t2]='0';
    t1--;
    t2--;
    }
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            {
                s1=s1.substr(n1-m1+1);
                n1=s1.length()-1;
            }
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
           {
               s2=s2.substr(n2-m2+1);
               n2=s2.length()-1;
           }
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
int n1=s1.length()-1,n2=s2.length()-1;
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            s1[n1-m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
            s2[n2-m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    if(i<str.size())
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<str.size()&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            s1[n1-m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
            s2[n2-m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(i>-1&&str[i]=='1')
            {
                if(i+1<ssz)
                str=str.substr(i+1);
                else
                    str="0";
                return true;
            }
       else if(i+1>-1&&i+1<ssz&&str[i+1]=='1')
        {
            return (isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
while(n1>-1&&n2>-1)
    {
     if(s1[n1]=='1'&&s2[n2]=='1')
    s1[n1]=s2[n2]='0';
   --n1;
   --n2;
    }
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
n1=s1.length()-1,n2=s2.length()-1;

    int y=1;
while(true)
{
if(s1=="0")
{
    if(s2=="0")
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(s2=="0")
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            {
                s1=s1.substr(n1-m1+1);
                if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
                n1=s1.size()-1,n2=s2.size()-1;
            }
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
           {
               s2=s2.substr(n2-m2+1);
               if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
               n2=s2.size()-1,n1=s1.size()-1;
           }
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;
void clean(string &str)
{
    if(str.find_first_of('1')>100000)
        str="0";
    else
        str=str.substr(str.find_first_of('1'));
}
bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(i>-1&&str[i]=='1')
        {
            if(i+1<ssz)
                {
                    str=str.substr(i+1);
                    clean(str);
                }
            else
                str="0";
            return true;
        }
        else if(i+1>-1&&i+1<ssz&&str[i+1]=='1')
        {
            return (isThere(str,i+2));
        }
        else
            return false;
    }
    else
        return false;
}
int main()
{
    string s1,s2,s3;
    cin>>s1>>s2;
    int n1=s1.length()-1,n2=s2.length()-1;
    while(n1>-1&&n2>-1)
    {
        if(s1[n1]=='1'&&s2[n2]=='1')
            s1[n1]=s2[n2]='0';
        --n1;
        --n2;
    }
    clean(s1);
    clean(s2);
    n1=s1.length()-1,n2=s2.length()-1;
    int y=1;
    while(true)
    {
        if(s1=="0")
        {
            if(s2=="0")
            {
                cout<<'=';
                return 0;
            }
            else
            {
                cout<<'<';
                return 0;
            }
        }
        else
        {
            if(s2=="0")
            {
                cout<<'>';
                return 0;
            }
            else
            {
                int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
                if(m2<m1)
                {
                    if(isThere(s2,n2-m1))
                    {
                        s1=s1.substr(n1-m1+1);
                        clean(s1);
                        n1=s1.size()-1,n2=s2.size()-1;
                    }
                    else
                    {
                        cout<<'>';
                        return 0;
                    }

                }
                else
                {
                    if(isThere(s1,n1-m2))
                    {
                        s2=s2.substr(n2-m2+1);
                        clean(s2);
                        n2=s2.size()-1,n1=s1.size()-1;
                    }
                    else
                    {
                        cout<<'<';
                        return 0;
                    }

                }

            }
        }
    }

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(i>-1&&str[i]=='1')
            {
                if(i+1<ssz)
                str=str.substr(i+1);
                else
                    str="0";
                return true;
            }
       else if(i+1>-1&&i+1<ssz&&str[i+1]=='1')
        {
            return (isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
while(n1>-1&&n2>-1)
    {
     if(s1[n1]=='1'&&s2[n2]=='1')
    s1[n1]=s2[n2]='0';
   --n1;
   --n2;
    }
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
n1=s1.length()-1,n2=s2.length()-1;

    int y=1;
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            {
                s1=s1.substr(n1-m1+1);
                n1=s1.length()-1;
            }
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
           {
               s2=s2.substr(n2-m2+1);
               n2=s2.length()-1;
           }
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;
bool isThere(string &str,int i)
{
    if(i<str.size())
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<str.size()&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
while(t1>-1&&t2>-1)
    {
     if(s1[t1]=='1'&&s2[t2]=='1')
    s1[t1]=s2[t2]='0';
    t1--;
    t2--;
    }
if(s1.size()>s2.size())
{
    for(int i=0;i<s1.size()-s2.size();++i)
        s3+='0';
    s3+=s2;
    s2=s3;
}else
{
      for(int i=0;i<s2.size()-s1.size();++i)
        s3+='0';
    s3+=s1;
    s1=s3;
}
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=s1.find_first_of('1'),m2=s2.find_first_of('1');
    if(m2>m1)
    {
        if(isThere(s2,m1))
            s1[m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,m2))
            s2[m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(i>-1&&str[i]=='1')
            {
                if(i+1<ssz)
                str=str.substr(i+1);
                else
                    str="0";
                return true;
            }
       else if(i+1>-1&&i+1<ssz&&str[i+1]=='1')
        {
            return (isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
while(n1>-1&&n2>-1)
    {
     if(s1[n1]=='1'&&s2[n2]=='1')
    s1[n1]=s2[n2]='0';
   --n1;
   --n2;
    }
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
n1=s1.length()-1,n2=s2.length()-1;

    int y=1;
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            {
                s1=s1.substr(n1-m1+1);
                n1=s1.size()-1,n2=s2.size()-1;
            }
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
           {
               s2=s2.substr(n2-m2+1);
               n2=s2.size()-1,n1=s1.size()-1;
           }
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;
bool isThere(string &str,int i)
{
    if(i<str.size())
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<str.size()&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
if(s1.size()>s2.size())
{
    for(int i=0;i<s1.size()-s2.size();++i)
        s3+='0';
    s3+=s2;
    s2=s3;
}else
{
      for(int i=0;i<s2.size()-s1.size();++i)
        s3+='0';
    s3+=s1;
    s1=s3;
}
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=s1.find_first_of('1'),m2=s2.find_first_of('1');
    if(m2>m1)
    {
        if(isThere(s2,m1))
            s1[m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,m2))
            s2[m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
while(t1>-1&&t2>-1)
    {
     if(s1[t1]=='1'&&s2[t2]=='1')
    s1[t1]=s2[t2]='0';
    t1--;
    t2--;
    }
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            s1=s1.substr(n1-m1+1);
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
            s2=s2.substr(n2-m2+1);
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
while(t1>-1&&t2>-1)
    {
     if(s1[t1]=='1'&&s2[t2]=='1')
    s1[t1]=s2[t2]='0';
    t1--;
    t2--;
    }
while(true)
{
    if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            s1[n1-m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
            s2[n2-m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
int n1=s1.length()-1,n2=s2.length()-1;
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            s1[n1-m1]='0';
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
            s2[n2-m2]='0';
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include<iostream>
using namespace std;

bool isThere(string &str,int i)
{
    int ssz=str.size();
    if(i<ssz)
    {
        if(str[i]=='1')
            {
                str[i]='0';
                return true;
            }
       else if(i+1<ssz&&str[i+1]=='1')
        {
            str[i+1]='0';
            return (true&&isThere(str,i+2));
        }
            else
            return false;
    }
        else
        return false;
}
bool one(string s)
{
    for(int i=0;i<s.length();++i)
        if(s[i]=='1')
        return true;
    return false;
}
int main(){
string s1,s2,s3;
cin>>s1>>s2;
if(s1.find_first_of('1')>100000)
    s1="0";
else
s1=s1.substr(s1.find_first_of('1'));
if(s2.find_first_of('1')>100000)
    s2="0";
else
s2=s2.substr(s2.find_first_of('1'));
int n1=s1.length()-1,n2=s2.length()-1;
int t1=n1,t2=n2;
while(t1>-1&&t2>-1)
    {
     if(s1[t1]=='1'&&s2[t2]=='1')
    s1[t1]=s2[t2]='0';
    t1--;
    t2--;
    }
while(true)
{
if(!one(s1))
{
    if(!one(s2))
    {
        cout<<'=';
        return 0;
    }else
    {
        cout<<'<';
        return 0;
    }
}else
{
    if(!one(s2))
        {
            cout<<'>';
        return 0;
        }
    else
        {
    int m1=n1-s1.find_first_of('1'),m2=n2-s2.find_first_of('1');
    if(m2<m1)
    {
        if(isThere(s2,n2-m1))
            {
                s1=s1.substr(n1-m1+1);
                n1=s1.length()-1;
            }
        else
        {
            cout<<'>';
            return 0;
        }

    }else
    {
        if(isThere(s1,n1-m2))
           {
               s2=s2.substr(n2-m2+1);
               n2=s2.length()-1;
           }
        else
            {
            cout<<'<';
        return 0;
        }

    }

}
    }
}

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}

ll T;
vector<pair<pii, pii>> vp;
void cal(int x, int y, ll t) {
    if (t==0) return;
    vp.push_back({{x+1,y-1}, {x+1,y}});
    if (t>5) {
        vp.push_back({{x,y+2}, {x,y+3}});
        vp.push_back({{x+1,y+2}, {x+1,y+3}});
        vp.push_back({{x,y+4}, {x+1,y+4}});
        if (x-2>=1)vp.push_back({{x-2,y+3}, {x-1,y+3}});

        vp.push_back({{x+2,y}, {x+3,y}});
        vp.push_back({{x+2,y+1}, {x+3,y+1}});
        vp.push_back({{x+4,y}, {x+4,y+1}});
        if (y-2>=1)vp.push_back({{x+3,y-2}, {x+3,y-1}});
    }
    int num = t%6;
    if (num==0) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 1) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 2) {
        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 3) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 4) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 5) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    }
    m+=2;
    cal(x+2, y+2, t/6);
}
void fmain() {
    cin>>T;
    m=2; vp.push_back({{1,2},{2,2}});
    vp.push_back({{2,1},{2,2}});
    cal(2, 2, T);
    printf("%d %d\n",m,m);
    printf("%d\n", vp.size());
    for(auto p : vp) {
        printf("%d %d %d %d\n",p.first.first,p.first.second,
               p.second.first,p.second.second);
    }
}
int main() {
    fmain();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}

ll T;
vector<pair<pii, pii>> vp;
void cal(int x, int y, ll t) {
    if (t==0) return;
    vp.push_back({{x+1,y-1}, {x+1,y}});
    if (t>5) {
        vp.push_back({{x,y+2}, {x,y+3}});
        vp.push_back({{x+1,y+2}, {x+1,y+3}});
        vp.push_back({{x,y+4}, {x+1,y+4}});
        if (x-2>=1)vp.push_back({{x-2,y+3}, {x-1,y+3}});

        vp.push_back({{x+2,y}, {x+3,y}});
        vp.push_back({{x+2,y+1}, {x+3,y+1}});
        vp.push_back({{x+4,y}, {x+4,y+1}});
        if (y-2>=1)vp.push_back({{x+3,y-2}, {x+3,y-1}});
    }
    int num = t%6;
    if (num==0) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 1) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 2) {
        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 3) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 4) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 5) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    }
    m+=2;
    cal(x+2, y+2, t/6);
}
void fmain() {
    cin>>T;
    ll x=0;
    while(T>0) {
        x=x*6+T%6;
        T/=6;
    }
    m=2; vp.push_back({{1,2},{2,2}});
    vp.push_back({{2,1},{2,2}});
    cal(2, 2, x);
    printf("%d %d\n",m,m);
    printf("%d\n", vp.size());
    for(auto p : vp) {
        printf("%d %d %d %d\n",p.first.first,p.first.second,
               p.second.first,p.second.second);
    }
}
int main() {
    fmain();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}

ll T;
vector<pair<pii, pii>> vp;
vector<int> V;
void cal(int x, int y, int pos) {
    if (pos==V.size()) return;
    vp.push_back({{x+1,y-1}, {x+1,y}});
    if (pos<V.size()-1) {
        vp.push_back({{x,y+2}, {x,y+3}});
        vp.push_back({{x+1,y+2}, {x+1,y+3}});
        vp.push_back({{x,y+4}, {x+1,y+4}});
        if (x-2>=1)vp.push_back({{x-2,y+3}, {x-1,y+3}});

        vp.push_back({{x+2,y}, {x+3,y}});
        vp.push_back({{x+2,y+1}, {x+3,y+1}});
        vp.push_back({{x+4,y}, {x+4,y+1}});
        if (y-2>=1)vp.push_back({{x+3,y-2}, {x+3,y-1}});
    }
    int num = V[pos];
    if (num==0) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 1) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 2) {
        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 3) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 4) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 5) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    }
    m+=2;
    cal(x+2, y+2, pos+1);
}
void fmain() {
    cin>>T;
    while(T>0) {
        V.push_back(T%6);
        T/=6;
    }
    reverse(V.begin(), V.end());
    m=2; vp.push_back({{1,2},{2,2}});
    vp.push_back({{2,1},{2,2}});
    cal(2, 2, 0);
    printf("%d %d\n",m,m);
    printf("%d\n", vp.size());
    for(auto p : vp) {
        printf("%d %d %d %d\n",p.first.first,p.first.second,
               p.second.first,p.second.second);
    }
}
int main() {
    fmain();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et() {
    puts("-1"); exit(0);
}

ll T;
vector<pair<pii, pii>> vp;
void cal(int x, int y, ll t) {
    if (t==0) return;
    vp.push_back({{x+1,y-1}, {x+1,y}});
    if (t>5) {
        vp.push_back({{x,y+2}, {x,y+3}});
        vp.push_back({{x+1,y+2}, {x+1,y+3}});
        vp.push_back({{x,y+4}, {x+1,y+4}});
        if (x-2>=1)vp.push_back({{x-2,y+3}, {x-1,y+3}});

        vp.push_back({{x+2,y}, {x+3,y}});
        vp.push_back({{x+2,y+1}, {x+3,y+1}});
        vp.push_back({{x+4,y}, {x+4,y+1}});
        if (y-2>=1)vp.push_back({{x+3,y-2}, {x+3,y-1}});
    }
    int num = t%6;
    if (num==0) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 1) {
        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 2) {
        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    } else if (num == 3) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 4) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
        vp.push_back({{x+2,y-1},{x+2,y}});
    }else if (num == 5) {
//        vp.push_back({{x-1,y+1},{x,y+1}});
//        vp.push_back({{x-1,y+2},{x,y+2}});
//        vp.push_back({{x+2,y-1},{x+2,y}});
    }
    m+=2;
    cal(x+2, y+2, t/6);
}
void fmain() {
    cin>>T;
    ll x=0;
    while(T>0) {
        cout<<T%6<<endl; x=x*6+T%6;
        T/=6;
    }
    m=2; vp.push_back({{1,2},{2,2}});
    vp.push_back({{2,1},{2,2}});
    cal(2, 2, x);
    printf("%d %d\n",m,m);
    printf("%d\n", vp.size());
    for(auto p : vp) {
        printf("%d %d %d %d\n",p.first.first,p.first.second,
               p.second.first,p.second.second);
    }
}
int main() {
    fmain();
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

namespace input {
    template<class T> void re(complex<T>& x);
    template<class T1, class T2> void re(pair<T1,T2>& p);
    template<class T> void re(vector<T>& a);
    template<class T, size_t SZ> void re(array<T,SZ>& a);

    template<class T> void re(T& x) { cin >> x; }
    void re(double& x) { string t; re(t); x = stod(t); }
    void re(ld& x) { string t; re(t); x = stold(t); }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) {
        re(first); re(rest...);
    }

    template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
    template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
    template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
    template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T, size_t SZ> void pr(const array<T,SZ>& x);
    template<class T> void pr(const vector<T>& x);
    template<class T> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);

    template<class T> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
        pr(first); pr(rest...);
    }

    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.f,", ",x.s,"}");
    }
    template<class T> void prContain(const T& x) {
        pr("{");
        bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; // const needed for vector<bool>
        pr("}");
    }
    template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    template<class T> void pr(const vector<T>& x) { prContain(x); }
    template<class T> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }

    void ps() { pr("\n"); }
    template<class Arg> void ps(const Arg& first) {
        pr(first); ps(); // no space at end of line
    }
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
        pr(first," "); ps(rest...); // print w/ spaces
    }
}

using namespace output;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}

using namespace io;

template<class T> T invGeneral(T a, T b) {
    a %= b; if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b,a);
    return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
}

template<class T> struct modular {
    T val;
    explicit operator T() const { return val; }
    modular() { val = 0; }
    modular(const ll& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD;
    }

    friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
    friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
    friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }

    modular operator-() const { return modular(-val); }
    modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
    modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
    modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
    friend modular pow(modular a, ll p) {
        modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend modular inv(const modular& a) {
        auto i = invGeneral(a.val,MOD); assert(i != -1);
        return i;
    } // equivalent to return exp(b,MOD-2) if MOD is prime
    modular& operator/=(const modular& m) { return (*this) *= inv(m); }

    friend modular operator+(modular a, const modular& b) { return a += b; }
    friend modular operator-(modular a, const modular& b) { return a -= b; }
    friend modular operator*(modular a, const modular& b) { return a *= b; }

    friend modular operator/(modular a, const modular& b) { return a /= b; }
};

typedef modular<int> mi;
typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;

ll T;
vi v;
vector<pair<pi,pi>> ans;

int main() {
    setIO(); re(T);
    while (T) {
    	v.pb(T%6);
    	T /= 6;
    }
    reverse(all(v));
    ans.pb({{2,1},{2,2}});
    ans.pb({{1,2},{2,2}});
    int n;
    F0R(i,sz(v)) {
		vector<pair<pi,pi>> tmp;
    	if (i != sz(v)-1) {
    		tmp.pb({{4,2},{5,2}});
    		tmp.pb({{5,2},{6,2}});
    		tmp.pb({{4,3},{5,3}});
    		tmp.pb({{5,1},{6,1}});
    		F0Rd(j,4) tmp.pb({{tmp[j].f.s,tmp[j].f.f},{tmp[j].s.s,tmp[j].s.f}});
    	} else {
    		n = 2*i+4;
    	}
    	int lef = v[i];
    	if (lef >= 3) lef -= 3;
    	else tmp.pb({{1,3},{2,3}});
    	if (lef >= 3) lef -= 3;
    	else tmp.pb({{3,1},{3,2}});
    	if (lef) lef --;
    	else tmp.pb({{1,4},{2,4}});
    	if (lef) lef --;
    	else tmp.pb({{4,1},{4,2}});
    	trav(t,tmp) {
			t.f.f += 2*i; t.f.s += 2*i;
			t.s.f += 2*i; t.s.s += 2*i;
    	}
		ans.insert(ans.end(),all(tmp));
    }
    ps(n,n);
    ps(sz(ans));
    trav(t,ans) if(abs(t.f.f-t.s.f)+abs(t.f.s-t.s.s) != 1) {
    	ps("HUH",t);
    	exit(0);
    }
    trav(t,ans) ps(t.f.f,t.f.s,t.s.f,t.s.s);
}

/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

namespace input {
    template<class T> void re(complex<T>& x);
    template<class T1, class T2> void re(pair<T1,T2>& p);
    template<class T> void re(vector<T>& a);
    template<class T, size_t SZ> void re(array<T,SZ>& a);

    template<class T> void re(T& x) { cin >> x; }
    void re(double& x) { string t; re(t); x = stod(t); }
    void re(ld& x) { string t; re(t); x = stold(t); }
    template<class Arg, class... Args> void re(Arg& first, Args&... rest) {
        re(first); re(rest...);
    }

    template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
    template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
    template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
    template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T, size_t SZ> void pr(const array<T,SZ>& x);
    template<class T> void pr(const vector<T>& x);
    template<class T> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);

    template<class T> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
        pr(first); pr(rest...);
    }

    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.f,", ",x.s,"}");
    }
    template<class T> void prContain(const T& x) {
        pr("{");
        bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; // const needed for vector<bool>
        pr("}");
    }
    template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    template<class T> void pr(const vector<T>& x) { prContain(x); }
    template<class T> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }

    void ps() { pr("\n"); }
    template<class Arg> void ps(const Arg& first) {
        pr(first); ps(); // no space at end of line
    }
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
        pr(first," "); ps(rest...); // print w/ spaces
    }
}

using namespace output;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}

using namespace io;

template<class T> T invGeneral(T a, T b) {
    a %= b; if (a == 0) return b == 1 ? 0 : -1;
    T x = invGeneral(b,a);
    return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
}

template<class T> struct modular {
    T val;
    explicit operator T() const { return val; }
    modular() { val = 0; }
    modular(const ll& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD;
    }

    friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
    friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
    friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }

    modular operator-() const { return modular(-val); }
    modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
    modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
    modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
    friend modular pow(modular a, ll p) {
        modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
        return ans;
    }
    friend modular inv(const modular& a) {
        auto i = invGeneral(a.val,MOD); assert(i != -1);
        return i;
    } // equivalent to return exp(b,MOD-2) if MOD is prime
    modular& operator/=(const modular& m) { return (*this) *= inv(m); }

    friend modular operator+(modular a, const modular& b) { return a += b; }
    friend modular operator-(modular a, const modular& b) { return a -= b; }
    friend modular operator*(modular a, const modular& b) { return a *= b; }

    friend modular operator/(modular a, const modular& b) { return a /= b; }
};

typedef modular<int> mi;
typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;

ll T;
vi v;
vector<pair<pi,pi>> ans;

int main() {
    setIO(); re(T);
    while (T) {
    	v.pb(T%6);
    	T /= 6;
    }
    reverse(all(v));
    ans.pb({{2,1},{2,2}});
    ans.pb({{1,2},{2,2}});
    int n;
    F0R(i,sz(v)) {
		vector<pair<pi,pi>> tmp;
    	if (i != sz(v)-1) {
    		tmp.pb({{4,2},{5,2}});
    		tmp.pb({{5,2},{6,2}});
    		tmp.pb({{4,3},{5,3}});
    		tmp.pb({{5,1},{6,1}});
    		F0Rd(j,4) tmp.pb({{tmp[j].f.s,tmp[j].s.s},{tmp[j].f.f,tmp[j].s.f}});
    	} else {
    		n = 2*i+4;
    	}
    	int lef = v[i];
    	if (lef >= 3) lef -= 3;
    	else tmp.pb({{1,3},{2,3}});
    	if (lef >= 3) lef -= 3;
    	else tmp.pb({{3,1},{3,2}});
    	if (lef) lef --;
    	else tmp.pb({{1,4},{2,4}});
    	if (lef) lef --;
    	else tmp.pb({{4,1},{4,2}});
    	trav(t,tmp) {
			t.f.f += 2*i; t.f.s += 2*i;
			t.s.f += 2*i; t.s.s += 2*i;
    	}
		ans.insert(ans.end(),all(tmp));
    }
    ps(n,n);
    ps(sz(ans));
    trav(t,ans) ps(t.f.f,t.f.s,t.s.f,t.s.s);
}

/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author majk
 */

#ifndef MAJK_LIB
#define MAJK_LIB

#include <vector>
#include <stack>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <bitset>
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<ui,ui> puu;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; }
ui logceil(int x) { return x?8*sizeof(int)-__builtin_clz(x):0; }

namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; }
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename F> double bshd(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){l=m;}else{h=m;}}return (l+h)/2;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename F> double bsld(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){h=m;}else{l=m;}}return (l+h)/2;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector2<T>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector2<T>>(a,vector2<T>(b,c,t)){}};
template<typename T>class vector4:public vector<vector3<T>>{public:vector4(){} vector4(size_t a,size_t b,size_t c,size_t d,T t=T()):vector<vector3<T>>(a,vector3<T>(b,c,d,t)){}};
template<typename T>class vector5:public vector<vector4<T>>{public:vector5(){} vector5(size_t a,size_t b,size_t c,size_t d,size_t e,T t=T()):vector<vector4<T>>(a,vector4<T>(b,c,d,e,t)){}};

#endif
// #include "../l/mod.h"

class TaskD {
public:
void solve(istream& cin, ostream& cout) {
    int Z = 50;
    ll L; cin >> L;

    ll P = 1;
    vector<pair<pii,pii>> Ans;
    for (int i = 0; i <= Z-6; i += 2) {
        int M = L % 6;
        L = L/6;
        P *= 6;

        Ans.push_back({{i+1,i+4},{i+1,i+5}});
        Ans.push_back({{i+1,i+5},{i+2,i+5}});
        Ans.push_back({{i+1,i+6},{i+2,i+6}});
        if (i != Z-6) Ans.push_back({{i+2,i+6},{i+2,i+7}});

        Ans.push_back({{i+4,i+1},{i+5,i+1}});
        Ans.push_back({{i+5,i+1},{i+5,i+2}});
        Ans.push_back({{i+6,i+1},{i+6,i+2}});
        if (i != Z-6) Ans.push_back({{i+6,i+2},{i+7,i+2}});

        if (M == 0 || M == 3) Ans.push_back({{i+1,i+3},{i+1,i+4}});
        if (M < 3) Ans.push_back({{i+2,i+3},{i+2,i+4}});
        Ans.push_back({{i+2,i+4},{i+3,i+4}});
        Ans.push_back({{i+2,i+5},{i+3,i+5}});

        if (M != 2 && M != 5) Ans.push_back({{i+3,i+1},{i+4,i+1}});
        Ans.push_back({{i+3,i+2},{i+4,i+2}});
        Ans.push_back({{i+4,i+2},{i+4,i+3}});
        Ans.push_back({{i+5,i+2},{i+5,i+3}});

    }

    if (L == 0) Ans.push_back({{Z-1,Z-3}, {Z,Z-3}});
    Ans.push_back({{Z-1,Z-2}, {Z,Z-2}});
    Ans.push_back({{Z-1,Z-1}, {Z,Z-1}});

    Ans.push_back({{Z-3,Z-1}, {Z-3,Z}});
    Ans.push_back({{Z-2,Z-1}, {Z-2,Z}});
    Ans.push_back({{Z-1,Z-1}, {Z-1,Z}});

    cout << Ans.size() << endl;
    for (auto ans: Ans) {
        cout << ans << endl;
    }

//    vector<string> C(2*Z, string(2*Z, ' '));
//    for (int i = 0; i < Z; ++i) {
//        for (int j = 0; j < Z; ++j) {
//            C[2*i+1][2*j+1] = '+';
//        }
//    }
//    for (auto a:Ans) {
//        C[a.x.x + a.y.x - 2][a.x.y + a.y.y - 2] = 'X';
//    }
//    for (string s: C) cout << s << endl;
//    cout << P << endl;
}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author majk
 */

#ifndef MAJK_LIB
#define MAJK_LIB

#include <vector>
#include <stack>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <bitset>
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<ui,ui> puu;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; }
ui logceil(int x) { return x?8*sizeof(int)-__builtin_clz(x):0; }

namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; }
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename F> double bshd(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){l=m;}else{h=m;}}return (l+h)/2;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename F> double bsld(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){h=m;}else{l=m;}}return (l+h)/2;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector2<T>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector2<T>>(a,vector2<T>(b,c,t)){}};
template<typename T>class vector4:public vector<vector3<T>>{public:vector4(){} vector4(size_t a,size_t b,size_t c,size_t d,T t=T()):vector<vector3<T>>(a,vector3<T>(b,c,d,t)){}};
template<typename T>class vector5:public vector<vector4<T>>{public:vector5(){} vector5(size_t a,size_t b,size_t c,size_t d,size_t e,T t=T()):vector<vector4<T>>(a,vector4<T>(b,c,d,e,t)){}};

#endif
// #include "../l/mod.h"

class TaskD {
public:
void solve(istream& cin, ostream& cout) {
    int Z = 50;
    ll L; cin >> L;

    ll P = 1;
    vector<pair<pii,pii>> Ans;
    for (int i = 0; i <= Z-6; i += 2) {
        int M = L % 6;
        L = L/6;
        P *= 6;

        Ans.push_back({{i+1,i+4},{i+1,i+5}});
        if (i != Z-6) Ans.push_back({{i+2,i+6},{i+2,i+7}});

        Ans.push_back({{i+4,i+1},{i+5,i+1}});
        if (i != Z-6) Ans.push_back({{i+6,i+2},{i+7,i+2}});

        if (M == 0 || M == 3) Ans.push_back({{i+1,i+3},{i+1,i+4}});
        if (M < 3) Ans.push_back({{i+2,i+3},{i+2,i+4}});
        Ans.push_back({{i+2,i+4},{i+3,i+4}});
        Ans.push_back({{i+2,i+5},{i+3,i+5}});

        if (M != 2 && M != 5) Ans.push_back({{i+3,i+1},{i+4,i+1}});
        Ans.push_back({{i+3,i+2},{i+4,i+2}});
        Ans.push_back({{i+4,i+2},{i+4,i+3}});
        Ans.push_back({{i+5,i+2},{i+5,i+3}});

    }

    if (L == 0) Ans.push_back({{Z-1,Z-3}, {Z,Z-3}});
    Ans.push_back({{Z-1,Z-2}, {Z,Z-2}});
    Ans.push_back({{Z-1,Z-1}, {Z,Z-1}});

    Ans.push_back({{Z-3,Z-1}, {Z-3,Z}});
    Ans.push_back({{Z-2,Z-1}, {Z-2,Z}});
    Ans.push_back({{Z-1,Z-1}, {Z-1,Z}});

    cout << "50 50\n";
    cout << Ans.size() << endl;
    for (auto ans: Ans) {
        cout << ans << endl;
    }

//    vector<string> C(2*Z, string(2*Z, ' '));
//    for (int i = 0; i < Z; ++i) {
//        for (int j = 0; j < Z; ++j) {
//            C[2*i+1][2*j+1] = '+';
//        }
//    }
//    for (auto a:Ans) {
//        C[a.x.x + a.y.x - 2][a.x.y + a.y.y - 2] = 'X';
//    }
//    for (string s: C) cout << s << endl;
//    cout << P << endl;
}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author majk
 */

#ifndef MAJK_LIB
#define MAJK_LIB

#include <vector>
#include <stack>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
#include <bitset>
using namespace std;

#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef pair<ui,ui> puu;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template <typename T> bool in(T a, T b, T c) { return a <= b && b < c; }
ui logceil(int x) { return x?8*sizeof(int)-__builtin_clz(x):0; }

namespace std { template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}}; }
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename F> double bshd(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){l=m;}else{h=m;}}return (l+h)/2;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename F> double bsld(double l,double h,const F&f,double p=1e-9){ui r=3+(ui)log2((h-l)/p);while(r--){double m=(l+h)/2;if(f(m)){h=m;}else{l=m;}}return (l+h)/2;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector2<T>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector2<T>>(a,vector2<T>(b,c,t)){}};
template<typename T>class vector4:public vector<vector3<T>>{public:vector4(){} vector4(size_t a,size_t b,size_t c,size_t d,T t=T()):vector<vector3<T>>(a,vector3<T>(b,c,d,t)){}};
template<typename T>class vector5:public vector<vector4<T>>{public:vector5(){} vector5(size_t a,size_t b,size_t c,size_t d,size_t e,T t=T()):vector<vector4<T>>(a,vector4<T>(b,c,d,e,t)){}};

#endif
// #include "../l/mod.h"

class TaskD {
public:
void solve(istream& cin, ostream& cout) {
    int Z = 50;
    ll L; cin >> L;

    ll P = 1;
    vector<pair<pii,pii>> Ans;
    for (int i = 0; i <= Z-6; i += 2) {
        int M = L % 6;
        L = L/6;
        P *= 6;

        Ans.push_back({{i+1,i+4},{i+1,i+5}});
        Ans.push_back({{i+1,i+5},{i+2,i+5}});
        Ans.push_back({{i+1,i+6},{i+2,i+6}});
        if (i != Z-6) Ans.push_back({{i+2,i+6},{i+2,i+7}});

        Ans.push_back({{i+4,i+1},{i+5,i+1}});
        Ans.push_back({{i+5,i+1},{i+5,i+2}});
        Ans.push_back({{i+6,i+1},{i+6,i+2}});
        if (i != Z-6) Ans.push_back({{i+6,i+2},{i+7,i+2}});

        if (M == 0 || M == 3) Ans.push_back({{i+1,i+3},{i+1,i+4}});
        if (M < 3) Ans.push_back({{i+2,i+3},{i+2,i+4}});
        Ans.push_back({{i+2,i+4},{i+3,i+4}});
        Ans.push_back({{i+2,i+5},{i+3,i+5}});

        if (M != 2 && M != 5) Ans.push_back({{i+3,i+1},{i+4,i+1}});
        Ans.push_back({{i+3,i+2},{i+4,i+2}});
        Ans.push_back({{i+4,i+2},{i+4,i+3}});
        Ans.push_back({{i+5,i+2},{i+5,i+3}});

    }

    if (L == 0) Ans.push_back({{Z-1,Z-3}, {Z,Z-3}});
    Ans.push_back({{Z-1,Z-2}, {Z,Z-2}});
    Ans.push_back({{Z-1,Z-1}, {Z,Z-1}});

    Ans.push_back({{Z-3,Z-1}, {Z-3,Z}});
    Ans.push_back({{Z-2,Z-1}, {Z-2,Z}});
    Ans.push_back({{Z-1,Z-1}, {Z-1,Z}});

    cout << "50 50\n";
    cout << Ans.size() << endl;
    for (auto ans: Ans) {
        cout << ans << endl;
    }

//    vector<string> C(2*Z, string(2*Z, ' '));
//    for (int i = 0; i < Z; ++i) {
//        for (int j = 0; j < Z; ++j) {
//            C[2*i+1][2*j+1] = '+';
//        }
//    }
//    for (auto a:Ans) {
//        C[a.x.x + a.y.x - 2][a.x.y + a.y.y - 2] = 'X';
//    }
//    for (string s: C) cout << s << endl;
//    cout << P << endl;
}
};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;

int const nmax = 50;

struct Block{
  int x;
  int y;
  int x2;
  int y2;
  ll cost;
  bool operator < (Block const &a) const{
    return cost < a.cost;
  }
};

vector<Block> sol;

bool valid(int x, int y){
  return (1 <= x && x <= nmax) && (1 <= y && y <= nmax);
}

void addblock(int x, int y, int x2, int y2, ll cost){
  if(valid(x, y) && valid(x2, y2))
    sol.push_back({x, y, x2, y2, cost});
}

int main()
{
  ll paths;
  cin >> paths;
  int n, m;
  n = m = nmax;
  ll coef = 1;
  cout << n << " " << m << '\n';

  for(int i = nmax - 3; 1 <= i; i -= 2){
    addblock(i, i + 2, i, i + 3, coef);
    addblock(i, i + 3, i, i + 4, 0);
    addblock(i - 1, i + 3, i - 1, i + 4, 0);

    addblock(i + 1, i + 2, i + 1, i + 3, coef * 3);
    addblock(i + 2, i, i + 3, i, coef);
    addblock(i + 2, i + 1, i + 3, i + 1, 0);

    addblock(i + 3, i, i + 4, i, 0);
    addblock(i + 3, i - 1, i + 4, i - 1, 0);

    addblock(i, i + 1, i - 1, i + 1, 0);
    addblock(i, i + 2, i - 1, i + 2, 0);

    addblock(i + 1, i, i + 1, i - 1, 0);
    addblock(i + 2, i, i + 2, i - 1, 0);

    coef = coef * 6;
  }
  addblock(nmax - 1, nmax - 1, nmax - 1, nmax, 0);
  addblock(nmax - 1, nmax - 1, nmax, nmax - 1, 0);
  sort(sol.begin(), sol.end());
  vector<Block> newsol;

  for(int i = sol.size() - 1; 0 <= i; i--){
    if(0 < sol[i].cost && sol[i].cost <= paths) {
      paths -= sol[i].cost;
    } else
      newsol.push_back(sol[i]);
  }

  cout << newsol.size() << '\n';
  for(int i = 0; i < newsol.size(); i++) {
    if(newsol[i].x2 + newsol[i].y2 < newsol[i].x + newsol[i].y) {
      swap(newsol[i].x2, newsol[i].x);
      swap(newsol[i].y2, newsol[i].y);
    }
    cout << newsol[i].x << " " << newsol[i].y << " " << newsol[i].x2 << " " << newsol[i].y2 << '\n';
  }
  return 0;
}


#include<iostream>
#include<string>
#include<map>
#include<vector>
#define ll long long
using namespace std;
using pii = pair<int, int>;
int main(void){
    int t;
    cin >> t;
    while(t --){
        string line;
        int len;
        cin >> len;
        cin >> line;
        int x = 0, y = 0;
        vector<pii> arr;
        arr.push_back(make_pair(0, 0));
        for(char c : line){
            if(c == 'U') y++;
            else if(c == 'D') y --;
            else if(c == 'L') x --;
            else x ++;
            arr.push_back(make_pair(x, y));
        }
        map<pii, int> mem;
        int l = 0, r = 0x3f3f3f3f;
        bool isOK = false;
        for(int i = 0; i < arr.size(); i ++){
            if(mem.count(arr[i]) == 0) mem[arr[i]] = i;
            else{
                isOK = true;
                if(r - l > i - mem[ arr[i] ]){
                    l = mem[arr[i]];
                    r = i;
                }
            }
        }
        l ++;
        if(!isOK) cout << -1 << endl;
        else cout << l << " " << r << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int l = 0, r = 0, u = 0, d = 0;
		int best_diff = 1e9;
		int x =0, y = 0;
		int endx = 0, endy = 0;
		bool find = false;
		for(int i = 0;i<n;i++)
		{
			if(str[i]=='L')
			{
				endx--;
				l++;
				u = 0;
				d = 0;
			}
			else if(str[i]=='R')
			{
				endx++;
				r++;
				u = 0;
				d=0;
			}
			else if(str[i]=='D')
			{
				endy--;
				d++;
				r=0;
				l=0;
			}
			else
			{
				endy++;
				u++;
				r = 0;
				l = 0;
			}
			//cout<<i<<" "<<l<<" "<<r<<" "<<u<<" "<<d<<endl;
			if(u == 0 && d == 0 && r == l && r != 0)
			{
				if(abs(r + l) < best_diff)
				{
					best_diff = abs(r + l);
					x = i - (r + l) + 1; y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			else if(u == d && r == 0 && l == 0 && u!=0)
			{
				if(abs(u + d) < best_diff)
				{
					best_diff = abs(u + d);
					x = i -(u + d) + 1;
					y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
		}
		if(endx == 0 && endy == 0 && find == false)
			cout<<1<<" "<<n<<endl;
		else if(find == false)
			cout<<-1<<endl;
		else
			cout<<x + 1<<" "<<y+1<<endl;

	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int l = 0, r = 0, u = 0, d = 0;
		int best_diff = 1e9;
		int x =0, y = 0;
		int endx = 0, endy = 0;
		bool find = false;
		for(int i = 0;i<n;i++)
		{
			if(str[i]=='L')
			{
				endx--;
				l++;
				u = 0;
				d = 0;
			}
			else if(str[i]=='R')
			{
				endx++;
				r++;
				u = 0;
				d=0;
			}
			else if(str[i]=='D')
			{
				endy--;
				d++;
				r=0;
				l=0;
			}
			else
			{
				endy++;
				u++;
				r = 0;
				l = 0;
			}
			//cout<<i<<" "<<l<<" "<<r<<" "<<u<<" "<<d<<endl;
			if(u == 0 && d == 0 && r == l && r  > 0 && l > 0)
			{
				if(abs(r + l) <= best_diff)
				{
					best_diff = abs(r + l);
					x = i - (r + l) + 1; y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			else if(u == d && r == 0 && l == 0 && u > 0 && d > 0)
			{
				if(abs(u + d) <= best_diff)
				{
					best_diff = abs(u + d);
					x = i -(u + d) + 1;
					y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			if(i >= 3)
			{
				if(str[i] != str[i -1] && str[i -1] != str[i - 2] && str[i - 3] != str[i - 2])
				{
					if(4 < best_diff){
					find = true;
					x = i -3;
					y = i;
					}
				}
			}
			else
				continue;
		}
		if(endx == 0 && endy == 0 && find == false)
			cout<<1<<" "<<n<<endl;
		else if(find == false)
			cout<<-1<<endl;
		else
			cout<<x + 1<<" "<<y+1<<endl;

	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		map<pair<int,int> , int> um;
		um[make_pair(0,0)] = 1;
		int x = 0, y = 0;
		int bestl = 0, bestr =	n + 1;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			if(um[make_pair(x,y)])
			{
				if(i - um[make_pair(x,y)] < bestr - bestl)
					bestl = um[make_pair(x,y)], bestr = i;
			}
			um[make_pair(x,y)] = i + 2;
		}
		if(bestl == 0)
			cout<<-1<<endl;
		else
			cout<<bestl<<" "<<bestr+1<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int l = 0, r = 0, u = 0, d = 0;
		int best_diff = 1e9;
		int x =0, y = 0;
		int endx = 0, endy = 0;
		bool find = false;
		for(int i = 0;i<n;i++)
		{
			if(str[i]=='L')
			{
				endx--;
				l++;
				u = 0;
				d = 0;
			}
			else if(str[i]=='R')
			{
				endx++;
				r++;
				u = 0;
				d=0;
			}
			else if(str[i]=='D')
			{
				endy--;
				d++;
				r=0;
				l=0;
			}
			else
			{
				endy++;
				u++;
				r = 0;
				l = 0;
			}
			//cout<<i<<" "<<l<<" "<<r<<" "<<u<<" "<<d<<endl;
			if(u == 0 && d == 0 && r == l && r  > 0 && l > 0)
			{
				if(abs(r + l) <= best_diff)
				{
					best_diff = abs(r + l);
					x = i - (r + l) + 1; y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			else if(u == d && r == 0 && l == 0 && u > 0 && d > 0)
			{
				if(abs(u + d) <= best_diff)
				{
					best_diff = abs(u + d);
					x = i -(u + d) + 1;
					y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			if(i >= 3)
			{
				if(str[i] != str[i -1] && str[i -1] != str[i - 2] && str[i - 3] != str[i - 2])
				{
					find = true;
					x = i -3;
					y = i;
				}
			}
			else
				continue;
		}
		if(endx == 0 && endy == 0 && find == false)
			cout<<1<<" "<<n<<endl;
		else if(find == false)
			cout<<-1<<endl;
		else
			cout<<x + 1<<" "<<y+1<<endl;

	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endX = 0, endY = 0;
		for(int i =0;i<n;i++)
		{
			if(str[i]=='L')
				endX--;
			else if(str[i]=='R')
				endX++;
			else if(str[i]=='D')
				endY--;
			else
				endY++;
		}
		int last = -1;
		int x =0, y= 0;
		vector<int> arr;
		for(int i =0;i<n;i++){
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			if(endX == x && endY == y && i + 1 != n){
				last = i + 1;
				arr.push_back(i + 1);
			}
		}
		int best = 1e9;
		x=0, y=0;
		arr.push_back(n);
		for(int i =0;i<arr.size()-1;i++)
		{
			//cout<<"range "<<arr[i]<<" "<<arr[i + 1]<<endl;
			if(arr[i + 1] - arr[i] < best)
			{
				best = arr[i + 1] - arr[i];
				x = arr[i] + 1, y = arr[i + 1];
			}
			else
				continue;
		}
		if(endX == 0 && endY == 0 && arr.size() == 1)
			cout<<1<<" "<<n<<endl;
		else if(best == 1e9)
			cout<<-1<<endl;
		else
			cout<<x<<" "<<y<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int l = 0, r = 0, u = 0, d = 0;
		int best_diff = 1e9;
		int x =0, y = 0;
		int endx = 0, endy = 0;
		bool find = false;
		for(int i = 0;i<n;i++)
		{
			if(str[i]=='L')
			{
				endx--;
				l++;
				u = 0;
				d = 0;
			}
			else if(str[i]=='R')
			{
				endx++;
				r++;
				u = 0;
				d=0;
			}
			else if(str[i]=='D')
			{
				endy--;
				d++;
				r=0;
				l=0;
			}
			else
			{
				endy++;
				u++;
				r = 0;
				l = 0;
			}
			//cout<<i<<" "<<l<<" "<<r<<" "<<u<<" "<<d<<endl;
			if(u == 0 && d == 0 && r == l && r  > 0 && l > 0)
			{
				if(abs(r + l) <= best_diff)
				{
					best_diff = abs(r + l);
					x = i - (r + l) + 1; y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			else if(u == d && r == 0 && l == 0 && u > 0 && d > 0)
			{
				if(abs(u + d) <= best_diff)
				{
					best_diff = abs(u + d);
					x = i -(u + d) + 1;
					y = i;
					find = true;
				}
				//cout<<x<<" "<<y<<endl;
			}
			else
				continue;
		}
		if(endx == 0 && endy == 0 && find == false)
			cout<<1<<" "<<n<<endl;
		else if(find == false)
			cout<<-1<<endl;
		else
			cout<<x + 1<<" "<<y+1<<endl;

	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endx = 0, endy = 0, x = 0, y = 0;
		for(int i =0;i<n;i++)
		{
			if(str[i]=='L')
				endx--;
			else if(str[i]=='R')
				endx++;
			else if(str[i]=='D')
				endy--;
			else
				endy++;
		}
		int diff = 1e9;
		int bestx = 0, besty = 0;
		if(endx == 0 && endy==0)
		{
			diff = n;
			bestx = 0, besty = n - 1;
		}
		vector<int> Arr;
		for(int i =0;i<n;i++)
		{
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			if(endx == x && endy== y)
			{
				Arr.push_back(i);
			}
		}
		for(int i =0;i<Arr.size()-1;i++)
		{
			int atf = Arr[i], ats = Arr[i + 1];
			int raz = ats - atf + 1;
			if(raz < diff)
			{
				diff = raz;
				bestx = atf + 1;
				besty = ats;
			}
		}
		if(diff == 1e9)
			cout<<-1<<endl;
		else
			cout<<bestx + 1<<" "<<besty+1<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endx = 0, endy=0;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				endx--;
			else if(str[i]=='R')
				endx++;
			else if(str[i]=='D')
				endy--;
			else
				endy++;
		}
		int best =1e9;
		int x = 0, y = 0;
		int bestx = -1, besty = -1;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			//cout<<i<<" "<<x<<" "<<y<<endl;
			if(x == endx && y == endy && i + 1 != str.size())
			{
				int diff = n - i -1;
				//cout<<diff<<" "<<i<<endl;
				if(diff <= best)
				{
					best = diff;
					bestx = i + 1, besty = n;
				}
			}
		}
		if(endx == 0 && endy == 0 && best == 1e9)
			cout<<1<<" "<<n<<endl;
		else if(best == 1e9)
			cout<<-1<<endl;
		else
			cout<<bestx+1<<" "<<besty<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endx = 0, endy=0;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				endx--;
			else if(str[i]=='R')
				endx++;
			else if(str[i]=='D')
				endy--;
			else
				endy++;
		}
		int best =1e9;
		int x = 0, y = 0;
		int bestx = -1, besty = -1;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			//cout<<i<<" "<<x<<" "<<y<<endl;
			if(x == endx && y == endy && i + 1 != str.size())
			{
				int diff = n - i -1;
				//cout<<diff<<" "<<i<<endl;
				if(diff < best)
				{
					best = diff;
					bestx = i + 1, besty = n;
				}
			}
		}
		if(endx == 0 && endy == 0 && best == 1e9)
			cout<<1<<" "<<n<<endl;
		else if(best == 1e9)
			cout<<-1<<endl;
		else
			cout<<bestx+1<<" "<<besty<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endx = 0, endy = 0, x = 0, y = 0;
		for(int i =0;i<n;i++)
		{
			if(str[i]=='L')
				endx--;
			else if(str[i]=='R')
				endx++;
			else if(str[i]=='D')
				endy--;
			else
				endy++;
		}
		int diff = 1e9;
		int bestx = 0, besty = 0;
		if(endx == 0 && endy==0)
		{
			diff = n;
			bestx = 0, besty = n - 1;
		}
		vector<int> arr;
		for(int i =0;i<n;i++)
		{
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			if(endx == x && endy== y)
			{
				arr.push_back(i);
			}
		}
		for(int i =0;i<arr.size()-1;i++)
		{
			int atf = arr[i], ats = arr[i + 1];
			int raz = ats - atf + 1;
			if(raz < diff)
			{
				diff = raz;
				bestx = atf + 1;
				besty = ats;
			}
		}
		if(diff == 1e9)
			cout<<-1<<endl;
		else
			cout<<bestx + 1<<" "<<besty+1<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endX = 0, endY = 0;
		for(int i =0;i<n;i++)
		{
			if(str[i]=='L')
				endX--;
			else if(str[i]=='R')
				endX++;
			else if(str[i]=='D')
				endY--;
			else
				endY++;
		}
		int last = -1;
		int x =0, y= 0;
		vector<int> arr;
		if(endX == 0 && endY == 0)
			arr.push_back(0);
		for(int i =0;i<n;i++){
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			if(endX == x && endY == y && i + 1 != n){
				last = i + 1;
				arr.push_back(i + 1);
			}
		}
		int best = 1e9;
		x=0, y=0;
		arr.push_back(n);
		for(int i =0;i<arr.size()-1;i++)
		{
			if(arr[i + 1] - arr[i] < best)
			{
				best = arr[i + 1] - arr[i];
				x = arr[i] + 1, y = arr[i + 1];
			}
			else
				continue;
		}
		if(best == 1e9 && endX != 0 && endY!=0)
			cout<<-1<<endl;
		else
			cout<<x<<" "<<y<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		string str;
		cin>>n>>str;
		int endx = 0, endy=0;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				endx--;
			else if(str[i]=='R')
				endx++;
			else if(str[i]=='D')
				endy--;
			else
				endy++;
		}
		int best =1e9;
		int x = 0, y = 0;
		int bestx = -1, besty = -1;
		for(int i =0;i<str.size();i++)
		{
			if(str[i]=='L')
				x--;
			else if(str[i]=='R')
				x++;
			else if(str[i]=='D')
				y--;
			else
				y++;

			if(x == endx && y == endy && i + 1 != str.size())
			{
				int diff = n - i -1;
				if(diff < best)
				{
					best = diff;
					x = i + 1, y = n;
				}
			}
		}
		if(endx == 0 && endy == 0 && best == 1e9)
			cout<<1<<" "<<n<<endl;
		else if(best == 1e9)
			cout<<-1<<endl;
		else
			cout<<x+1<<" "<<y<<endl;
	}
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 800004
using namespace std;
int set[HASH_LEN][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };

inline int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
int _hash(int y, int x) {
	return (y < 0 ? -y : y + x < 0 ? -x : x) % HASH_LEN;
}
void add(int curY, int curX,int pos) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1)
		key = (key + 1) % HASH_LEN;
	set[key][0] = key;
	set[key][1] = curY, set[key][2] = curX;
	set[key][3] = pos;
}
int find(int curY, int curX) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1) {
		if (set[key][1] == curY && set[key][2] == curX)
			return key;
		key = (key + 1) % HASH_LEN;
	}
	return -1;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;
		memset(set, -1, sizeof(set));
		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;
		int minLen = 0x7FFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			int h = find(curY, curX);
			if (h == -1) {
				add(curY, curX,i);
			} else {
				if (minLen > i - set[h][3]) {
					minLen = i - set[h][3];
					l = set[h][3] + 1;
					r = i;
					if (r - l == 1) break;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l , r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[400004];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		ll curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		int minLen = 0xFFFFFFF, l = -1, r = -1;

		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			ll cX = (curX + 200002L)*(curX + 200002L);
			ll cY = (curY + 200002L)*(curY + 200002L);
			int _key = (int)((cX + cY) % (ll)HASH_LEN);
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 800004
using namespace std;
int set[HASH_LEN][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
typedef long long int ll;
inline int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
inline int _hash(int y, int x) {
	return y * ((ll)y) + x * ((ll)x) % ((ll)HASH_LEN);
}
inline void add(int curY, int curX,int pos) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1)
		key = (key + 1) % HASH_LEN;
	set[key][0] = key;
	set[key][1] = curY, set[key][2] = curX;
	set[key][3] = pos;
}
inline int find(int curY, int curX) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1) {
		if (set[key][1] == curY && set[key][2] == curX)
			return key;
		key = (key + 1) % HASH_LEN;
	}
	return -1;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;
		memset(set, -1, sizeof(set));
		set[0][0] = _hash(0, 0), set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;
		int minLen = 0x7FFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			int h = find(curY, curX);
			if (h == -1) {
				add(curY, curX,i);
			} else {
				if (minLen > i - set[h][3]) {
					minLen = i - set[h][3];
					l = set[h][3] + 1;
					r = i;
					if (r - l == 1) break;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l , r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 800004
using namespace std;
int set[HASH_LEN][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
typedef long long int ll;
inline int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;
		memset(set, -1, sizeof(set));
		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;
		int minLen = 0x7FFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			int _key = (curY * ((ll)curY) + curX * ((ll)curX)) % ((ll)HASH_LEN);

			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
					if (r - l == 1) break;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include <map>
#include<string.h>
#define HASH_LEN 800004
using namespace std;
typedef unsigned long long ll;
int set[HASH_LEN][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };

inline int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
int _hash(int y, int x) {
	return (y < 0 ? -y : y + x < 0 ? -x : x) % HASH_LEN;
}
void add(int curY, int curX,int pos) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1)
		key = (key + 1) % HASH_LEN;
	set[key][0] = key;
	set[key][1] = curY, set[key][2] = curX;
	set[key][3] = pos;
}
int find(int curY, int curX) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1) {
		if (set[key][1] == curY && set[key][2] == curX)
			return key;
		key = (key + 1) % HASH_LEN;
	}
	return -1;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0;
		int minLen = 0x7FFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			int h = find(curY, curX);
			if (h == -1) {
				add(curY, curX,i);
			} else {
				if (minLen > i - set[h][3]) {
					minLen = i - set[h][3];
					l = set[h][3] + 1;
					r = i;
					if (r - l == 1) break;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l , r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include <map>
#define HASH_LEN 400004
using namespace std;
typedef unsigned long long ll;
int set[400004][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };

inline int* direct(char c) {
	switch (c) {
		case 'L':
			return dxdy[0];
		case 'R':
			return dxdy[1];
		case 'U':
			return dxdy[2];
		case 'D':
			return dxdy[3];
	}
}
int _hash(int y, int x) {
	return (y < 0 ? -y : y + x < 0 ? -x : x) % HASH_LEN;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		for (int i = 0; i < 200002; i++)
			set[i][0] = -1;

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0;
		int minLen = 0x7FFFFFFF,l=-1,r=-1;
		for (int i = 0; i < n; i++) {
			curX += direct(seq[i])[0];
			curY += direct(seq[i])[1];
			//printf("%c curX : %d curY %d\n", seq[i], curX, curY);
			int key = _hash(curY,curX);
			int found = false;
			while (set[key][0] != -1) {
				if (set[key][1] == curY && set[key][2] == curX) {
					found = true;
					break;
				}
				key = (key + 1) % HASH_LEN;
			}
			if (!found) {
				set[key][0] = key;
				set[key][1] = curY, set[key][2] = curX,set[key][3]=i;
			} else {
				if (minLen > i - set[key][1]) {
					minLen = i - set[key][3];
					l = set[key][3];
					r = i;
				}
			}
		}
		if(l<0)
			printf("-1\n");
		else
			printf("%d %d\n", l+1, r+1);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include <map>
#define HASH_LEN 400004
using namespace std;
typedef unsigned long long ll;
int set[400004][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };

inline int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
int _hash(int y, int x) {
	return (y < 0 ? -y : y + x < 0 ? -x : x) % HASH_LEN;
}
void add(int curY, int curX,int pos) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1)
		key = (key + 1) % HASH_LEN;
	set[key][0] = key;
	set[key][1] = curY, set[key][2] = curX;
	set[key][3] = pos;
}
int find(int curY, int curX) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1) {
		if (set[key][1] == curY && set[key][2] == curX)
			return key;
		key = (key + 1) % HASH_LEN;
	}
	return -1;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		for (int i = 0; i < HASH_LEN; i++)
			set[i][0] = -1;

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0;
		int minLen = 0x7FFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			int h = find(curY, curX);
			if (h == -1) {
				add(curY, curX,i);
			} else {
				if (minLen > i - set[h][3]) {
					minLen = i - set[h][3];
					l = set[h][3] + 1;
					r = i;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l , r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[400004];
char buf[100];

int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
inline unsigned long _hash(char *str)
{
	unsigned long hash = 5381;
	register int c;
	while (c = *str++) hash = ((hash << 5) + hash) + c;
	return hash;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));
		sprintf(buf, "%d %d", 0, 0);
		int _key = _hash(buf) % HASH_LEN;
		set[_key][0] = _key, set[_key][1] = 0, set[_key][2] = 0, set[_key][3] = 0;

		int minLen = 0xFFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			sprintf(buf,"%d %d", curX, curY);

			int _key = _hash(buf) % HASH_LEN;
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[200004];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		int minLen = 0x7FFFFFFF, l = -1, r = -1;

		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			int _key = (int)((((curY * (ll)curY) << 32) + (curX * (ll)curX)) % ((ll)HASH_LEN));
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}
			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include <map>
#define HASH_LEN 4000004
using namespace std;
typedef unsigned long long ll;
int set[HASH_LEN][4];
char seq[200002];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };

inline int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}
int _hash(int y, int x) {
	return (y < 0 ? -y : y + x < 0 ? -x : x) % HASH_LEN;
}
void add(int curY, int curX,int pos) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1)
		key = (key + 1) % HASH_LEN;
	set[key][0] = key;
	set[key][1] = curY, set[key][2] = curX;
	set[key][3] = pos;
}
int find(int curY, int curX) {
	int key = _hash(curY, curX);
	while (set[key][0] != -1) {
		if (set[key][1] == curY && set[key][2] == curX)
			return key;
		key = (key + 1) % HASH_LEN;
	}
	return -1;
}
int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		for (int i = 0; i < HASH_LEN; i++)
			set[i][0] = -1;

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0;
		int minLen = 0x7FFFFFFF, l = -1, r = -1;
		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];
			int h = find(curY, curX);
			if (h == -1) {
				add(curY, curX,i);
			} else {
				if (minLen > i - set[h][3]) {
					minLen = i - set[h][3];
					l = set[h][3] + 1;
					r = i;
					if (r - l == 1) break;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l , r);
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<istream>
#include<string.h>
#define HASH_LEN 300000
using namespace std;
typedef long long int ll;
int set[HASH_LEN][4];
char seq[200004];
int dxdy[4][2] = { {-1,0},{1,0},{0,1},{0,-1} };
int* direct(char c) {
	switch (c) {
	case 'L':
		return dxdy[0];
	case 'R':
		return dxdy[1];
	case 'U':
		return dxdy[2];
	case 'D':
		return dxdy[3];
	}
}

int main() {
	int TC;
	scanf("%d", &TC);
	for (int tc = 0; tc < TC; tc++) {
		int n = 0;
		scanf("%d", &n);
		scanf("%s", &seq);
		int curX = 0, curY = 0;

		memset(set, -1, sizeof(set));

		set[0][0] = 0, set[0][1] = 0, set[0][2] = 0, set[0][3] = 0;

		int minLen = 0x7FFFFFFF, l = -1, r = -1;

		for (int i = 1; i <= n; i++) {
			curX += direct(seq[i - 1])[0];
			curY += direct(seq[i - 1])[1];

			int _key = (int)((((curY * (ll)curY) << 32) + (curX * (ll)curX)) % ((ll)HASH_LEN));
			if((int)_key < 0 )
				printf("err %d %d", curY, curX);
			while (set[_key][0] != -1) {
				if (set[_key][1] == curY && set[_key][2] == curX)
					break;
				_key = (_key + 1) % HASH_LEN;
			}

			if (set[_key][0] == -1) {
				set[_key][0] = _key;
				set[_key][1] = curY, set[_key][2] = curX;
				set[_key][3] = i;
			}
			else {
				if (minLen > i - set[_key][3]) {
					minLen = i - set[_key][3];
					l = set[_key][3] + 1;
					r = i;
				}
			}
		}
		if (l < 0)
			printf("-1\n");
		else
			printf("%d %d\n", l, r);
	}
	return 0;
}