Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test=list(input().split())
- dic={"a":1,"b":1,"c":1,"d":2,"e":2,"f":2,"g":3,"h":3,"i":3,"j":4,"k":4,"l":4,"m":5,"n":5,"o":5,"p":6,"q":6,"r":6,"s":6,"t":7,"u":7,"v":7,"w":8,"x":8,"y":9,"z":9}
- A=test[2:]
- if test[0].isdigit():
- for _ in range(int(test[0])):
- m=int(test[1])
- tempdic=dict()
- for i in A:
- key=''
- for j in i:
- key+=str(dic[j])
- tempdic[int(key)]=tempdic.get(int(key),0)+1
- ans=max(tempdic,key=lambda x:tempdic[x])
- print(ans)
- else:
- A=test[2:]
- tempdic=dict()
- for i in A:
- key=''
- for j in i:
- key+=str(dic[j])
- tempdic[int(key)]=tempdic.get(int(key),0)+1
- ans=max(tempdic,key=lambda x:tempdic[x])
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment