WA3.. Don't know error
I'm not getting the bug in the code :(. It would be helpful if someone pointed the mistake.
key = {'i' : 1, 'j' : 1,
'a' : 2, 'b' : 2, 'c' : 2,
'd' : 3, 'e' : 3, 'f' : 3,
'g' : 4, 'h' : 4,
'k' : 5, 'l' : 5,
'm' : 6, 'n' : 6,
'p' : 7, 'r' : 7, 's' : 7,
't' : 8, 'u' : 8, 'v' : 8,
'w' : 9, 'x' : 9, 'y' : 9,
'o' : 0, 'q' : 0, 'z' : 0
}
while True:
n = raw_input()
if(int(n) == -1):
break
l = int(raw_input())
d = {}
ans = []
for a0 in xrange(l):
temp = raw_input()
d["".join([str(key[i]) for i in temp])] = temp
i = len(n)
while(i>0):
if n[0:i] in d.keys():
ans.append(d[n[0:i]])
n = n[i:]
i = len(n)+1
i-=1
print "No solution." if len(n) != 0 else " ".join(ans)