s=input().split(',')
print(s)
s=[i.split(':') for i in s]
print(s)
res=''
for i in range(len(s)):
    if(str(len(s[i][0])) in s[i][1]):
        res+=s[i][0][-1]
    else:
        flag=0
        length=len(s[i][0])-1
        while(length>0):
            if(str(length) in s[i][1]):
                res+=s[i][0][length-1]
                flag=1
                break
            else:
                length-=1
        if(flag==0):
            res+='X'
print(res)        

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: