#include <stdio.h>

int main() {
    unsigned int languageNum = 0;
    unsigned int publishingHouseNum = 0;
    unsigned int publishingNum = 0;
    char identityNum = 0;
    while (
        scanf("%u-%u-%u-%c", &languageNum, &publishingHouseNum,&publishingNum,&identityNum) != EOF
        ) 
    {

        if (identityNum == 'X')
        {
            identityNum = 58;
        }

        
        int judgeIdentityNum = 0;
        judgeIdentityNum += languageNum * 1;
        for (int i = 1000, j = 2; i>=10 && j<=4; i/=10,j++)
        {
            judgeIdentityNum += ((int)((publishingHouseNum % i)/(i/10))) * j;
        }
        for (long i = 100000, j = 5; i>=10 && j<=9; i/=10,j++)
        {
            judgeIdentityNum += ((int)((publishingNum % i)/(i/10))) * j;
        }

        if (judgeIdentityNum % 11 == identityNum-48)
        {
            printf("Right");
        }
        else 
        {
            if (judgeIdentityNum % 11 == 10)
            {
                printf("%u-%u-%u-X",languageNum,publishingHouseNum,publishingNum);
            }
            else 
            {
                printf("%u-%u-%u-%d",languageNum,publishingHouseNum,publishingNum,judgeIdentityNum%11);
            }
            
        }
        

    }
    
    return 0;
}