def solution(msg):
answer = []
dict = {}
for i in range(65,65+26):
dict[chr(i)] = i-65+1
while len(msg)>0:
if len(msg) == 1:
answer.append(dict[msg])
break
temp = msg[0]
idx = 0
while len(temp) < len(msg):
now = temp
idx+=1
temp+=msg[idx]
if temp not in dict:
temp = now
break
answer.append(dict[temp])
msg = msg[len(temp):]
if msg:
dict[temp+msg[0]] = len(dict)+1
return answer