#gives position
import codecs

filem = codecs.open("malayalam.txt","r",encoding="utf-8")
#fileeng = open ("english.txt","r")
out = codecs.open ("test.txt","a",encoding="utf-8")
malword=filem.readline()

while malword != "" :

    #engword=fileeng.readline().lower()
    i=0
    while malword[i] !="$":

        out.write(malword[i])
        exp = malword[i+1] == "ി"or malword[i+1] =="ാ"or malword[i+1] == "ീ"or malword[i+1] == "ു"or malword[i+1] == "ൂ"or malword[i+1] == "ൃ"or malword[i+1] == "ൗ"
        exp2= malword[i+1] ==  "േ" or malword[i+1] =="ൈ"or malword[i+1] =="ോ"or malword[i+1] =="ൌ"or malword[i+1] =="െ" or malword[i+1] =="്"or malword[i+1] == "ം"
        if ( exp or exp2 or malword[i+1] =="ൊ"):
            out.write(malword[i+1])
            if i==0:
                out.write(" 1")
            elif malword[i+2] == "$" :
                out.write(" 3")
            else:
                out.write(" 2 ")
            out.write("\n")
            i=i+2
        else:
            if i==0:
                out.write(" 1")
            elif malword[i+1] == "$" :
                out.write(" 3")
            else:
                out.write(" 2")

            i=i+1
            out.write("\n")
    malword=filem.readline()
