Problem:


ポケベル打ち

ある日、たろう君は、本文に「519345213244」という数字だけが書いてあるおかしなメールを受け取り
ました。そのメールは、10 歳年上の従姉からだったので電話して聞いてみると、「あ、急いでたから
ポケベル打ちで送っちゃった。便利よね。よろしくねっ!」といって切られてしまいました。いつも
せわしなく、少し強引なところのあるこの従姉をよく知るたろう君は、仕方なく自分で「ポケベル打
ち」について調べてみると、10 年ぐらい前に一世を風靡したかな入力の方法だということが分かりまし
た。

「ポケベル打ち」では、図 1 のような変換表に従い‘あ’は 11、‘お’は 15 という具合に、2 つの数字
で一つの文字を入力していきます。例えば「なると」という文字列を入力するには「519345」と打ちま
す。従って、どの文字も 2 つの数字で入力することができるのです。

図1

携帯電話がまだ広く普及していないころ、高校生はこの方法で公衆電話から友達のポケベルにメッセー
ジを送信していたのだそうです。猛烈なスピードでポケベル打ちができる女子高生もいたとか。最近、
仕事も忙しくなってきた従姉は、メールを無意識のうちにポケベル打ちでタイプするようになってしま
いました。

 そこで、毎回解読に苦労しているたろう君を助けるために、ポケベル打ちによるメッセージを文字列
に変換し出力するプログラムを作成してください。ただし、変換には図2の変換表を使い、英
小文字及び、「.」、「?」、「!」、空白のみを対象とします。変換出来ない文字を含むメッセージに対しては NA と出力してください。

図2

Input

複数のメッセージが与えられます。各行に１つのメッセージ (200 文字以内) が与えられます。メッセージの総数は 50 を超えません。

Output

各メッセージに対して、変換後のメッセージまたは NA を１行に出力してください。

Sample Input

341143514535
314
143565553551655311343411652235654535651124615163
551544654451431564
4
3411
6363636363
153414

Output for the Sample Input

naruto
NA
do you wanna go to aizu?
yes sure!
NA
na
?????
end



Sample input:
341143514535
314
143565553551655311343411652235654535651124615163
551544654451431564
4
3411
6363636363
153414


Sample output:
naruto
NA
do you wanna go to aizu?
yes sure!
NA
na
?????
end

Submission status: Wrong Answer

Solution code:
encode = {
	"11":"a",
	"12":"b",
	"13":"c",
	"14":"d",
	"15":"e",
	"21":"f",
	"22":"g",
	"23":"h",
	"24":"i",
	"25":"j",
	"31":"k",
	"32":"l",
	"33":"m",
	"34":"n",
	"35":"o",
	"41":"p",
	"42":"q",
	"43":"r",
	"44":"s",
	"45":"t",
	"51":"u",
	"52":"v",
	"53":"w",
	"54":"x",
	"55":"y",
	"61":"z",
	"62":".",
	"63":"?",
	"64":"!",
	"65":" "
	}

while True:
	try:
		source = raw_input()
	except EOFError:
		break
	
	code = ""
	judge = True
	for i in range(0, len(code), 2):
		if source[i:i+2] in encode:
			code += encode[source[i:i+2]]
		else:
			judge = False
			break
		
	if judge:
		print code
	else:
		print "NA"

Submission status: Wrong Answer

Solution code:
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


code = {1: "afkpuz", 2: "ablqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}

def pocket_pager(string):
    if len(string) % 2 == 1:
        return "NA"
    res = ""
    for k in range(len(string) // 2):
        i = int(string[2*k])
        j = int(string[2*k+1])
        if not 1 <= i <= 6 or not 1 <= j <= 5:
            return "NA"
        res += code[j][i-1]
    return res


for line in sys.stdin:
    print(pocket_pager(line.strip()))

Submission status: Wrong Answer

Solution code:
dic = {}
base = ord("a")
for x in range(5):
  for y in range(5):
    dic[(x + 1, y + 1)] = chr(base + x * 5 + y)
dic[(6, 1)] = "z"
dic[(6, 2)] = "."
dic[(6, 3)] = "?"
dic[(6, 4)] = "!"
dic[(6, 5)] = " "

def to_mess(nums):
  if len(nums) % 2 == 1:
    return "NA"
  
  mess = ""
  for i in range(0, len(nums), 2):
    x, y = map(int, nums[i: i + 2])
    if (x, y) in dic:
      mess += dic[(x, y)]

  return mess

while True:
  try:
    nums = input()
    print(to_mess(nums))
  except EOFError:
    break

Submission status: Wrong Answer

Solution code:
def splitstr(str,num):
    l =[]
    l = [str[i::num] for i in range(num)]
    l=["".join(i) for i in zip(*l)]
    rem = len(str) % num
    if rem: l.append(str[-rem:])
    return l

a = [[0 for i in range(5)] for j in range(6)]
q=97
for i in range(5):
    for j in range(5):
        a[i][j] = chr(q)
        q+=1
a[5][0] = 'z'
a[5][1] = '.'
a[5][2] = '?'
a[5][3] = '!'
a[5][4] = ' '
def main():
    me=raw_input()
    me = splitstr(me,2)
    ans=""
    for i in me:
        ans+=a[int(i[0])-1][int(i[1])-1]
    print ans
if __name__ == '__main__':
    while True:
        try:
            main()
        except IndexError: print "NA";continue
        except EOFError: break

Submission status: Wrong Answer

Solution code:
def splitstr(str,num):
    l =[]
    l = [str[i::num] for i in range(num)]
    l=["".join(i) for i in zip(*l)]
    rem = len(str) % num
    if rem: l.append(str[-rem:])
    return l
 
a = [[0 for i in range(5)] for j in range(6)]
q=97
for i in range(5):
    for j in range(5):
        a[i][j] = chr(q)
        q+=1
for i,j in enumerate('z.?! '): a[5][i] = j
def main():
    me=raw_input()
    me = splitstr(me,2)
    ans=""
    for i in me:
        ans+=a[int(i[0])-1][int(i[1])-1]
    print ans
if __name__ == '__main__':
    while True:
        try:
            main()
        except IndexError: print "NA";continue
        except EOFError: break
        except ValueError: print "NA"; continue

Submission status: Wrong Answer

Solution code:
decode = ["afkpuz",
          "bglqv.",
          "chmrw?",
          "dinsx!",
          "ejoty "]
while True:
    try:
        line = raw_input()
    except EOFError:
        break
    if len(line)%2 == 1:
        print "NA"
        continue
    try:
        print "".join(decode[j-1][i-1]
                      for i,j in zip(map(int,line[::2]),map(int,line[1::2])))
    except IndexError:
        print "NA"

Submission status: Wrong Answer

Solution code:
decode = ["afkpuz",
          "bglqv.",
          "chmrw?",
          "dinsx!",
          "ejoty "]
while True:
    try:
        line = map(int,list(raw_input()))
    except EOFError:
        break
    if len(line)%2 == 1:
        print "NA"
        continue
    try:
        print "".join(decode[j-1][i-1]
                      for i,j in zip(line[::2],line[1::2]))
    except IndexError:
        print "NA"

Submission status: Wrong Answer

Solution code:
decode = ["afkpuz",
          "bglqv.",
          "chmrw?",
          "dinsx!",
          "ejoty "]
while True:
    try:
        line = map(int,list(raw_input()))
    except EOFError:
        break
    if len(line)%2 == 1:
        print "NA"
        continue
    try:
        print "".join(decode[j-1][i-1]
                      for i,j in zip(line[::2],line[1::2]))
    except:
        print "NA"

Submission status: Wrong Answer

Solution code:
ref="abcdefghijklmnopqrstuvwxyz.?! "
while 1:
	try:
		msg=raw_input()
		ans=""
		for i in range(0,len(msg),2):
			try:
				ans+=ref[(int(msg[i])-1)*5+int(msg[i+1])-1]
			except:
				print "NA"
				break
		else:
			print ans
	except:
		break

Submission status: Wrong Answer

Solution code:
ref="abcdefghijklmnopqrstuvwxyz.?! "
while 1:
	try:
		inp=raw_input()
		msg=""
		for i in range(0,len(inp),2):
			try:
				msg+=ref[(int(inp[i])-1)*5+int(inp[i+1])-1]
			except:
				msg="NA"
				break
		print msg
	except:
		break

Submission status: Wrong Answer

Solution code:
ref=["abcde","fghij","klmno","pqrst","uvwxy","z.?! "]
while 1:
	try:
		inp=raw_input()
		msg=""
		for i in range(0,len(inp),2):
			try:
				msg+=ref[int(inp[i])-1][int(inp[i+1])-1]
			except:
				msg="NA"
				break
		print msg
	except:
		break

Submission status: Wrong Answer

Solution code:
ref=["abcde","fghij","klmno","pqrst","uvwxy","z.?! "]
while 1:
	try:
		inp=raw_input()
		if len(inp)%2==1:
			print "NA"
			continue
		msg=""
		for i in range(0,len(inp),2):
			r,c=map(int,inp[i:i+2])
			if c>-1:
				msg+=ref[r-1][c-1]
			else:
				msg="NA"
				break
		print msg
	except:
		break

Submission status: Wrong Answer

Solution code:
ref=["abcde","fghij","klmno","pqrst","uvwxy","z.?! "]
while 1:
	try:
		inp=raw_input()
		msg=""
		for i in range(0,len(inp),2):
			try:
				r,c=map(int,inp[i:i+2])
				msg+="a"*min(0,c-1)+ref[r-1][c-1]
			except:
				msg="NA"
				break
		print msg
	except:
		break

Submission status: Accepted

Solution code:
import sys
d={}
L="abcdefghijklmnopqrstuvwxyz.?! "
p=0
for i in range(30): d[(i/5)*10+i%5+11]=L[i]
for s in sys.stdin:
  s=s[:-1]
  s=[s[i:i+2] for i in range(0,len(s),2)]
  try: A=[d[e] for e in map(int,s)]
  except: A=["NA"]
  print "".join(A)

Submission status: Accepted

Solution code:
import sys

s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

for line in sys.stdin:
    line = line.rstrip()
    if len(line) == 0 or len(line) % 2 != 0:
        print 'NA'
        continue
    ans = ''
    for i in range(0, len(line), 2):
        if (line[i],line[i+1]) in d:
            ans += d[(line[i],line[i+1])]
        else:
            print 'NA'
            break
    else:
        print ans

Submission status: Accepted

Solution code:
import sys

s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

for line in sys.stdin:
    line = line.rstrip()
    if len(line) % 2 != 0:
        print 'NA'
        continue
    ans = ''
    for i in range(0, len(line), 2):
        if (line[i],line[i+1]) in d:
            ans += d[(line[i],line[i+1])]
        else:
            print 'NA'
            break
    else:
        print ans

Submission status: Accepted

Solution code:
M = "afkpuzbglqv.chmrw?dinsx!ejoty "
while True:
    try:
        s = raw_input()
        l = len(s)
        mes = ""
        if l&1:
            1/0
        for i in xrange(l/2):
            i1 = int(s[2*i])-1; i2 = int(s[2*i+1])-1
            if 0<=i1<=5 and 0<=i2<=4:
                mes += M[i1 + i2*6]
            else:
                1/0
        print mes
    except EOFError:
        break
    except Exception:
        print "NA"
        continue

Submission status: Accepted

Solution code:
table = {11:'a',12:'b',13:'c',14:'d',15:'e',
         21:'f',22:'g',23:'h',24:'i',25:'j',
         31:'k',32:'l',33:'m',34:'n',35:'o',
         41:'p',42:'q',43:'r',44:'s',45:'t',
         51:'u',52:'v',53:'w',54:'x',55:'y',
         61:'z',62:'.',63:'?',64:'!',65:' '}

while True:
    try:
        mes = input()
        ans = [table.get(int(mes[i:i+2]), 'NA') for i in range(0, len(mes), 2)]
        if 'NA' in ans:
            print('NA')
        else:
            print(''.join(ans))
    except: break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0127
"""
import sys
input = sys.stdin.readline


def decode(code):
    result = ''
    while code:
        try:
            c = code[:2]
            result += Code_table[c]
            code = code[2:]
        except:
            return 'NA'
    return result


Code_table = {
    '11': 'a', '21': 'f', '31': 'k', '41': 'p', '51': 'u', '61': 'z',
    '12': 'b', '22': 'g', '32': 'l', '42': 'q', '52': 'v', '62': '.',
    '13': 'c', '23': 'h', '33': 'm', '43': 'r', '53': 'w', '63': '?',
    '14': 'd', '24': 'i', '34': 'n', '44': 's', '54': 'x', '64': '!',
    '15': 'e', '25': 'j', '35': 'o', '45': 't', '55': 'y', '65': ' ',
}
def main(args):
    for line in sys.stdin:
        result = decode(line.strip())
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


code = {1: "afkpuz", 2: "bglqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}

def pocket_pager(string):
    if len(string) % 2 == 1:
        return "NA"
    res = ""
    for k in range(len(string) // 2):
        i = int(string[2*k])
        j = int(string[2*k+1])
        if not 1 <= i <= 6 or not 1 <= j <= 5:
            return "NA"
        res += code[j][i-1]
    return res


for line in sys.stdin:
    print(pocket_pager(line.strip()))

Submission status: Accepted

Solution code:
import sys

convert = {"1": {"1": "a", "2": "b", "3": "c", "4": "d", "5": "e"},
           "2": {"1": "f", "2": "g", "3": "h", "4": "i", "5": "j"},
           "3": {"1": "k", "2": "l", "3": "m", "4": "n", "5": "o"},
           "4": {"1": "p", "2": "q", "3": "r", "4": "s", "5": "t"},
           "5": {"1": "u", "2": "v", "3": "w", "4": "x", "5": "y"},
           "6": {"1": "z", "2": ".", "3": "?", "4": "!", "5": " "},
           }

for line in sys.stdin:
    line = line[:-1]

    if len(line) % 2 != 0:
        print("NA")
        continue

    message = ""

    line = iter(line)

    for first, second in zip(*[line, line]):

        if "1" <= first <= "6" and "1" <= second <= "5":
            message += convert.get(first).get(second)
        else:
            print("NA")
            break
    else:
        print(message)

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

table = \
["afkpuz",\
 "bglqv.",\
 "chmrw?",\
 "dinsx!",\
 "ejoty "]

N = list(get_input())
for l in range(len(N)):
    str = N[l]
    ans = ""
    if len(str) % 2 == 1:
        ans = "NA"
    else:
        for i in range(0,len(str),2):
            x = str[i]
            y = str[i+1]
            if "1" <= x and x <= "6" and "1" <= y and y <= "5":
                ans = ans + table[int(y)-1][int(x)-1]
            else:
                ans = "NA"
                break

    print(ans)

Submission status: Accepted

Solution code:
dic = {}
base = ord("a")
for x in range(5):
  for y in range(5):
    dic[(x + 1, y + 1)] = chr(base + x * 5 + y)
dic[(6, 1)] = "z"
dic[(6, 2)] = "."
dic[(6, 3)] = "?"
dic[(6, 4)] = "!"
dic[(6, 5)] = " "

def to_mess(nums):
  if len(nums) % 2 == 1:
    return "NA"
  
  mess = ""
  for i in range(0, len(nums), 2):
    x, y = map(int, nums[i: i + 2])
    if (x, y) in dic:
      mess += dic[(x, y)]
    else:
      return "NA"

  return mess

while True:
  try:
    nums = input()
    print(to_mess(nums))
  except EOFError:
    break

Submission status: Accepted

Solution code:
# AOJ 0127 Pocket Pager Input
# Python3 2018.6.18 bal4u

a = ['']*100

a[11], a[12], a[13], a[14], a[15] = 'a', 'b', 'c', 'd', 'e'
a[21], a[22], a[23], a[24], a[25] = 'f', 'g', 'h', 'i', 'j'
a[31], a[32], a[33], a[34], a[35] = 'k', 'l', 'm', 'n', 'o'
a[41], a[42], a[43], a[44], a[45] = 'p', 'q', 'r', 's', 't'
a[51], a[52], a[53], a[54], a[55] = 'u', 'v', 'w', 'x', 'y'
a[61], a[62], a[63], a[64], a[65] = 'z', '.', '?', '!', ' '

while True:
	try: buf = list(input())
	except: break
	
	f = True
	ans = ''
	for i in range(0, len(buf), 2):
		if i+1 >= len(buf):
			f = False
			break
		if buf[i].isdigit() and buf[i+1].isdigit():
			k = int(buf[i]+buf[i+1])
			if a[k] != '': ans += a[k]
			else:
				f = False
				break
	print(ans if f else "NA")

Submission status: Accepted

Solution code:
def splitstr(str,num):
    l =[]
    l = [str[i::num] for i in range(num)]
    l=["".join(i) for i in zip(*l)]
    rem = len(str) % num
    if rem: l.append(str[-rem:])
    return l
 
a = [[0 for i in range(5)] for j in range(6)]
q=97
for i in range(5):
    for j in range(5):
        a[i][j] = chr(q)
        q+=1
for i,j in enumerate('z.?! '): a[5][i] = j
 
while True:
    try:
        me = raw_input()
        if '0' in me: print "NA" ; continue
        me = splitstr(me,2)
        ans = ""
        for i in me:
            ans+=a[int(i[0])-1][int(i[1])-1]
        print ans
    except IndexError: print "NA" ; continue
    except EOFError: break
    except ValueError: print "NA" ; continue

Submission status: Accepted

Solution code:
import itertools
dic={"61":"z","62":".","63":"?","64":"!","65":" "}
cnt=ord("a")
for i in itertools.product(range(1,6),repeat=2):
    dic["".join(map(str,i))]=chr(cnt)
    cnt+=1

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    if len(s)%2!=0:
        print "NA"
    else:
        try:
            print "".join(dic[s[i:i+2]] for i in range(0,len(s),2))
        except KeyError:
            print "NA"

Submission status: Accepted

Solution code:
from sys import stdout

cs = {
    1: [None] + list("abcde"),
    2: [None] + list("fghij"),
    3: [None] + list("klmno"),
    4: [None] + list("pqrst"),
    5: [None] + list("uvwxy"),
    6: [None] + list("z.?! "),
}

while True:
    try:
        it = iter(raw_input().strip())
    except EOFError:
        break

    try:
        r = c = None
        s = []
        while True:
            r = int(it.next())
            c = int(it.next())
            s += [cs[r][c]]
            r = c = None
    except KeyError:
        stdout.write("NA\n")
    except IndexError:
        stdout.write("NA\n")
    except StopIteration:
        if not r and not c:
            stdout.write(''.join(s) + "\n")
        else:
            stdout.write("NA\n")
        continue

Submission status: Accepted

Solution code:
decode = ["afkpuz",
          "bglqv.",
          "chmrw?",
          "dinsx!",
          "ejoty "]

def check(i,j):
    return 0<=i<=5 and 0<=j<=4

while True:
    try:
        line = raw_input()
    except EOFError:
        break
    if len(line)%2 == 1:
        line += "9"
    ans = ""
    for i,j in zip(line[::2],line[1::2]):
        i,j = int(i)-1,int(j)-1
        if not check(i,j):
            print "NA"
            break
        ans += decode[j][i]
    else:
        print ans

Submission status: Accepted

Solution code:
decode = ["afkpuz",
          "bglqv.",
          "chmrw?",
          "dinsx!",
          "ejoty "]
while True:
    try:
        line = map(int,list(raw_input()))
    except EOFError:
        break
    if len(line)%2 == 1 or 0 in line:
        print "NA"
        continue
    try:
        print "".join(decode[j-1][i-1]
                      for i,j in zip(line[::2],line[1::2]))
    except IndexError:
        print "NA"

Submission status: Accepted

Solution code:
ref=["abcde","fghij","klmno","pqrst","uvwxy","z.?! "]
while 1:
	try:
		inp=raw_input()
		if len(inp)%2==1:
			print "NA"
			continue
		msg=""
		for i in range(0,len(inp),2):
			r,c=map(int,inp[i:i+2])
			if 1<=r<=6 and 1<=c<=5:
				msg+=ref[r-1][c-1]
			else:
				msg="NA"
				break
		print msg
	except:
		break

Submission status: Accepted

Solution code:
t = [["a","f","k","p","u","z"],["b","g","l","q","v","."],["c","h","m","r","w","?"],["d","i","n","s","x","!"],["e","j","o","t","y"," "]]

while 1:
    try:
        s = input()
        ans = ""
        i = 0
        l = len(s)
        
        if l % 2 == 0:
            while i < l:
                i1 = int(s[i + 1]) - 1
                i2 = int(s[i]) - 1
                if (i1 >= 0 and i1 <= 4) and (i2 >= 0 and i2 <= 5):
                    ans += t[i1][i2]
                else:
                    break
                i += 2
        if len(ans) * 2 != l:
            ans = "NA"
        print(ans)
    except:
        break

Submission status: Accepted

Solution code:



def message(numbers):
    numbers=str(numbers)
    message=""
    while(len(numbers)>0):
        num=numbers[:2]
        if len(num)==1:
            return "NA"
        if int(num[0])>6 or int(num[0])<=0:
            return "NA"
        if int(num[1])>5 or int(num[1])<=0:
            return "NA"
        code=(int(num[0])-1)*5+int(num[1])
        if code>30:
            return "NA"
        if code==27:
            message+="."
        elif code==28:
            message+="?"
        elif code==29:
            message+="!"
        elif code==30:
            message+=" "
        else:
            message+=chr(code-1+ord('a'))
        numbers=numbers[2::]
    return message


while True:
    try:
        n=input()
        print(message(n))
    except EOFError:
        break

Submission status: Accepted

Solution code:

L = []
L.append(list("abcde"))
L.append(list("fghij"))
L.append(list("klmno"))
L.append(list("pqrst"))
L.append(list("uvwxy"))
L.append(list("z.?! "))

while True:
    try:
        tmp = input()
        l = [int(x)-1 for x in list(tmp)]
    except:
        break
    if len(l) % 2 > 0:
        print("NA")
        continue

    ferr = 0
    M = []
    for i, j in zip(l[0::2],l[1::2]):
        if i not in range(len(L)) or j not in range(len(L[0])):
            ferr += 1
        else:
            M.append(L[i][j])
    if ferr > 0:
        print("NA")
    else:
        print("".join(M))

Submission status: Accepted

Solution code:
mes = {11:"a",12:"b",13:"c",14:"d",15: "e",21:"f",22:"g",23:"h",24:"i",25:"j"
    ,31:"k",32:"l",33:"m",34:"n",35:"o",41:"p",42:"q",43:"r",44:"s",45:"t"
    ,51:"u",52:"v",53:"w",54:"x",55:"y",61:"z",62:".",63:"?",64:"!",65:" "}
while True:
    try:N=input()
    except:break
    if len(N) % 2 == 1:print("NA");continue
    word=""
    for i in range(0,len(N),2):
        if int(N[i:i + 2]) in mes:word +=mes[int(N[i:i + 2])]
        else:word="NA";break
    print(word)

Submission status: Accepted

Solution code:
mes = {11:"a",12:"b",13:"c",14:"d",15:"e"
    ,21:"f",22:"g",23:"h",24:"i",25:"j"
    ,31:"k",32:"l",33:"m",34:"n",35:"o"
    ,41:"p",42:"q",43:"r",44:"s",45:"t"
    ,51:"u",52:"v",53:"w",54:"x",55:"y"
    ,61:"z",62:".",63:"?",64:"!",65:" "}

while True:
    try:
        s = input()
    except:
        break
    ss = ""
    for i in range(0, len(s), 2):
        if len(s) % 2 == 1:
            ss = "NA"
            break
        if int(s[i:i+2]) in mes:
            ss+=mes[int(s[i:i+2])]
        else:
            ss = "NA"
            break
    print(ss)

Submission status: Runtime Error

Solution code:
import sys

s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

for line in sys.stdin:
    line = line.rstrip()
    if len(line) % 2 != 0:
        print 'NA'
        continue
    ans = ''
    for i in range(0, len(line), 2):
        if d[(line[i],line[i+1])]:
            ans += d[(line[i],line[i+1])]
        else:
            print 'NA'
            break
    else:
        print ans

Submission status: Runtime Error

Solution code:
import sys

s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

for line in sys.stdin:
    line = line.rstrip()
    if len(line) == 0 or len(line) % 2 != 0:
        print 'NA'
        continue
    ans = ''
    for i in range(0, len(line), 2):
        if d[(line[i],line[i+1])]:
            ans += d[(line[i],line[i+1])]
        else:
            print 'NA'
            break
    else:
        print ans

Submission status: Runtime Error

Solution code:
s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

while True:
    try:
        line = raw_input()
        if len(line) == 0 or len(line) % 2 != 0:
            print 'NA'
            continue
        ans = ''
        for i in range(0, len(line), 2):
            if d[(line[i],line[i+1])]:
                ans += d[(line[i],line[i+1])]
            else:
                print 'NA'
                break
        else:
            print ans
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


code = {1: "afkpuz", 2: "ablqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}

def pocket_pager(string):
    if len(string) % 2 == 1:
        return "NA"
    res = ""
    for k in range(len(string) // 2):
        i = int(string[2*k])
        j = int(string[2*k+1])
        res += code[j][i-1]
    return res


for line in sys.stdin:
    print(pocket_pager(line.strip()))

Submission status: Runtime Error

Solution code:
import sys

convert = {"1": {"1": "a", "2": "b", "3": "c", "4": "d", "5": "e"},
           "2": {"1": "f", "2": "g", "3": "h", "4": "i", "5": "j"},
           "3": {"1": "k", "2": "l", "3": "m", "4": "n", "5": "o"},
           "4": {"1": "p", "2": "q", "3": "r", "4": "s", "5": "t"},
           "5": {"1": "u", "2": "v", "3": "w", "4": "x", "5": "y"},
           "6": {"1": "z", "2": ".", "3": "?", "4": "!", "5": " "},
           }

for line in sys.stdin:
    line = line[:-1]

    if len(line) % 2 != 0:
        print("NA")
        continue

    message = ""

    line = iter(line)

    for first, second in zip(*[line, line]):
        result = convert[first][second]

        if result != None:
            message += result
        else:
            print("NA")
            break
    else:
        print(message)

Submission status: Runtime Error

Solution code:
import sys

convert = {"1": {"1": "a", "2": "b", "3": "c", "4": "d", "5": "e"},
           "2": {"1": "f", "2": "g", "3": "h", "4": "i", "5": "j"},
           "3": {"1": "k", "2": "l", "3": "m", "4": "n", "5": "o"},
           "4": {"1": "p", "2": "q", "3": "r", "4": "s", "5": "t"},
           "5": {"1": "u", "2": "v", "3": "w", "4": "x", "5": "y"},
           "6": {"1": "z", "2": ".", "3": "?", "4": "!", "5": " "},
           }

for line in sys.stdin:
    line = line[:-1]

    if len(line) % 2 != 0:
        print("NA")
        continue

    message = ""

    line = iter(line)

    for first, second in zip(*[line, line]):
        result = convert.get(first).get(second)

        if result != None:
            message += result
        else:
            print("NA")
            break
    else:
        print(message)

Submission status: Runtime Error

Solution code:
import itertools
dic={"61":"z","62":".","63":"?","64":"!","65":" "}
cnt=ord("a")
for i in itertools.product(range(1,6),repeat=2):
    dic["".join(map(str,i))]=chr(cnt)
    cnt+=1

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    if len(s)%2!=0:
        print "NA"
    else:
        print "".join(dic[s[i:i+2]] for i in range(0,len(s),2))

Submission status: Runtime Error

Solution code:
from sys import stdout

cs = {
    1: [None] + list("abcde"),
    2: [None] + list("fghij"),
    3: [None] + list("klmno"),
    4: [None] + list("pqrst"),
    5: [None] + list("uvwxy"),
    6: [None] + list("z.?! "),
}

while True:
    try:
        it = iter(raw_input().strip())
    except ValueError:
        break

    try:
        r = c = None
        s = []
        while True:
            r = int(it.next())
            c = int(it.next())
            s += [cs[r][c]]
            r = c = None
    except IndexError:
        stdout.write("NA\n")
    except StopIteration:
        if not r and not c:
            stdout.write(''.join(s) + "\n")
        else:
            stdout.write("NA\n")
        continue

Submission status: Runtime Error

Solution code:
from sys import stdout

cs = {
    1: [None] + list("abcde"),
    2: [None] + list("fghij"),
    3: [None] + list("klmno"),
    4: [None] + list("pqrst"),
    5: [None] + list("uvwxy"),
    6: [None] + list("z.?! "),
}

while True:
    try:
        it = iter(raw_input().strip())
    except ValueError:
        break

    try:
        r = c = None
        s = []
        while True:
            r = int(it.next())
            c = int(it.next())
            s += [cs[r][c]]
            r = c = None
    except KeyError:
        stdout.write("NA\n")
    except IndexError:
        stdout.write("NA\n")
    except StopIteration:
        if not r and not c:
            stdout.write(''.join(s) + "\n")
        else:
            stdout.write("NA\n")
        continue

Submission status: Runtime Error

Solution code:
decode = ["afkpuz",
          "bglqv.",
          "chmrw?",
          "dinsx!",
          "ejoty "]
while True:
    try:
        line = raw_input()
    except EOFError:
        break
    if len(line)%2 == 1:
        print "NA"
        continue
    try:
        print "".join(decode[j-1][i-1]
                      for i,j in zip(map(int,line[::2]),map(int,line[1::2])))
    except KeyError:
        print "NA"