#include<iostream>
#include<string>
using namespace std;
int main()
{ string str;
int n;
int i,j,t;
int sum;
cin>>n;
cin.ignore();
while(n--){
getline(cin,str);
j=1;sum=0;
for(i=0;i<11;i++)
{ if((str[i]-'0')<=10&&(str[i]-'0')>=0)
sum+=(str[i]-'0')*j;
else
continue;
j++;
}
t=sum%11;
if(t!=10)
{if(t==str[12]-'0')
cout<<"Right"<<endl;
else
{
str[12]=t+'0';
for(i=0;i<13;i++)
cout<<str[i];
cout<<endl;}
}
else{
if(str[12]=='X')
cout<<"Right"<<endl;
else
{
str[12]=t+'0';
for(i=0;i<13;i++)
cout<<str[i];
cout<<endl;
}
}
}
}