Problem:


与えられた変換表にもとづき，データを変換するプログラムを作成しなさい．

データに使われている文字は英字か数字で，英字は大文字と小文字を区別する．変換表に現れる文字の順序に規則性はない．

変換表は空白をはさんで前と後ろの 2 つの文字がある(文字列ではない)．変換方法は，変換表のある行の前の文字がデータに現れたら，そのたびにその文字を後ろの文字に変換し出力する．変換は 1 度だけで，変換した文字がまた変換対象の文字になっても変換しない．変換表に現れない文字は変換せず，そのまま出力する．

入力ファイルには，変換表（最初の n + 1 行）に続き変換するデータ（n + 2 行目以降）が書いてある． 1 行目に変換表の行数 n，続く n 行の各行は，空白をはさんで 2 つの文字，さらに続けて， n + 2 行目に変換するデータの行数 m，続く m 行の各行は 1 文字である． m ≤ 105 とする．出力は，出力例のように途中に空白や改行は入れず 1 行とせよ．

 

  入力例
 

3

A a

0 5

5 4

10

A

B

C

0

1

4

5

a

b

A

  　

  出力例

aBC5144aba

入力

入力は複数のデータセットからなる．n が 0 のとき入力が終了する．データセットの数は 5 を超えない．

出力

データセットごとに、変換後の文字列を１行に出力する．

入力例

3	
A a	
0 5	
5 4	
10	
A	
B	
C	
0	
1	
4	
5	
a	
b	
A
3	
A a	
0 5	
5 4	
10	
A	
B	
C	
0	
1	
4	
5	
a	
b	
A
0

出力例

aBC5144aba
aBC5144aba

各データセットの出力（変換後の文字列）の後に改行を入れること．

上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
3
A a
0 5
5 4
10
A
B
C
0
1
4
5
a
b
A
3
A a
0 5
5 4
10
A
B
C
0
1
4
5
a
b
A
0


Sample output:
aBC5144aba
aBC5144aba

Submission status: Accepted

Solution code:
#list(map(int, input().split()))

while(1):
	N=int(input());
	if(N==0):
		break;

	MAP=[[0 for i in range(2)] for j in range(N)];
	for i in range(N):
		MAP[i][0],MAP[i][1]=input().split();

	N2=int(input());
	a=[0 for i in range(N2)];
	for i in range(N2):
		a[i]=input();

	for i in a:
		flag=0;
		for j in range(N):
			if(i[0]==MAP[j][0][0]):
				print(MAP[j][1][0],end="");
				flag=1;
				break;
		if(flag==0):
			print(i[0],end="");

	print();

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n == 0:
        break
    a = {}
    for i in range(n):
        x,y=input().split()
        a[x]=y
    m=int(input())
    s = ''
    for i in range(m):
        x = input()[0]
        if x in a.keys():
            s = s+a[x]
        else:
            s = s+x
    print(s)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    D = {}
    L = []
    for i in range(n):
        e = list(map(str,input().split()))
        L += e[0]
        D[e[0]] = e[1]
    k = int(input())
    S = ''
    for i in range(k):
        s = input().strip()
        if s in L:
            S += D[s]
        else:
            S += s
    print (S)

Submission status: Accepted

Solution code:

while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    m = int(input())

    s = ""
    for i in range(m):
        c = input()[0]
        if c in d:
            s += d[c]
        else:
            s += c
    print(s)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    dic = {}
    for i in range(n):
        x, y = input().split()
        dic[x] = y

    n = int(input())
    a = []
    for i in range(n):
        c = input().strip()
        if c in dic.keys():
            a.append(dic[c])
        else:
            a.append(c)

    print(''.join(a))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    for _ in range(n):
        x, y = input().split()
        d[x] = y
    m = int(input())
    result = ""
    for _ in range(m):
        x = input()[0]
        if x in d:
            result += d[x]
        else:
            result += x
    print(result)

Submission status: Accepted

Solution code:
n = int(input())
while n!=0 :
    conv = dict()
    for i in range(n):
        k,v = input().split()
        conv[k] = v
    out = ""
    n2 = int(input())
    for i in range(n2):
        befo = input()[0]
        if (befo in conv.keys()):
            befo = conv[befo]
        out += befo
    print(out)
    n = int(input())

Submission status: Accepted

Solution code:
while True:
	n = int(input())
	if n == 0: break
	tbl = {}
	for i in range(n):
		a, b = input().split()
		tbl[a] = b
	ans = ''
	m = int(input())
	for i in range(m):
		a = input()[0]
		ans += tbl[a] if a in tbl else a
	print(ans)

Submission status: Accepted

Solution code:
while True:
    try:
        n = input()
        if n == 0:
            break
        else:
            before = []
            after = []
            for i in range(n):
                lst = raw_input().split(' ')
                before.append(lst[0])
                after.append(lst[1])
            m = input()
            ans = ''
            for i in range(m):
                value = raw_input()[0]
                try:
                    ans += after[before.index(value)]
                except ValueError:
                    ans += value
            print ans
    except EOFError:
        break

Submission status: Runtime Error

Solution code:
def input_num(infile,outfile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	return dict

def replace(infile,outfile,dict,m):
	for i in range(m):
		x = infile.readline()
		x = dict.get(x,x)
		outfile.write(x)
	print >> outfile



if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin,sys.stdout)
		if n == 0:
			break
		dict = makedict(infile,outfile,n)
		# dict.update(makedict(infile,outfile,n))
		m = input_num(sys.stdin,sys.stdout)
		replace(infile,outfile,dict,m)

Submission status: Runtime Error

Solution code:
def input_num(infile,outfile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	return dict

def replace(infile,outfile,dict,m):
	for i in range(m):
		x = infile.readline().sprit()[0]
		x = dict.get(x,x)
		outfile.write(x)
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin,sys.stdout)
		if n == 0:
			break
		dict = makedict(infile,outfile,n)
		# dict.update(makedict(infile,outfile,n))
		m = input_num(sys.stdin,sys.stdout)
		replace(infile,outfile,dict,m)

Submission status: Runtime Error

Solution code:
def input_num(infile,outfile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	return dict

def replace(infile,outfile,dict,m):
	for i in range(m):
		x = infile.readline().sprit()[0]
		x = dict.get(x,x)
		outfile.write(x)
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin,sys.stdout)
		if n == 0:
			break
		dictionary = makedict(infile,outfile,n)
		# dict.update(makedict(infile,outfile,n))
		m = input_num(sys.stdin,sys.stdout)
		replace(infile,outfile,dictionary,m)

Submission status: Runtime Error

Solution code:
def input_num(infile,outfile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	return dict

def replace(infile,outfile,dict,m):
	for i in range(m):
		x = infile.readline().sprit()[0]
		x = dict.get(x,x)
		outfile.write(x)
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin,sys.stdout)
		if n == 0:
			break
		dictionary = makedict(infile,outfile,n)
		# dict.update(makedict(infile,outfile,n))
		m = input_num(sys.stdin,sys.stdout)
		replace(sys.stdin,sys.stdout,dictionary,m)

Submission status: Runtime Error

Solution code:
def input_num(infile,outfile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	return dict

def replace(infile,outfile,dict,m):
	for i in range(m):
		x = infile.readline().sprit()[0]
		x = dict.get(x,x)
		outfile.write(x)
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin,sys.stdout)
		if n == 0:
			break
		dictionary = makedict(sys.stdin,sys.stdout,n)
		# dict.update(makedict(infile,outfile,n))
		m = input_num(sys.stdin,sys.stdout)
		replace(sys.stdin,sys.stdout,dictionary,m)

Submission status: Runtime Error

Solution code:
def input_num(infile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	return dict

def replace(infile,outfile,dict,m):
	for i in range(m):
		x = infile.readline().sprit()[0]
		outfile.write(dict.get(x,x))
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin)
		if n == 0:
			break
		dictionary = makedict(sys.stdin,sys.stdout,n)
		# dict.update(makedict(infile,outfile,n))
		m = input_num(sys.stdin)
		replace(sys.stdin,sys.stdout,dictionary,m)

Submission status: Runtime Error

Solution code:
def input_num(infile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	m = input_num(sys.stdin)
	for j in range(m):
		x = infile.readline().sprit()[0]
		outfile.write(dict.get(x,x))
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin)
		if n == 0:
			break
		dictionary = makedict(sys.stdin,sys.stdout,n)

Submission status: Runtime Error

Solution code:
def input_num(infile):
	num = int(infile.readline())
	return num

def makedict(infile,outfile,n):
	dict = {}
	for i in range(n):
		key,val = infile.readline().split()
		dict[key] = val
	m = input_num(sys.stdin)
	for j in range(m):
		x = infile.readline().sprit()[0]
		outfile.write(dict.get(x,x))
	print >> outfile

if __name__ == "__main__"
	import sys
	while True:
		n = input_num(sys.stdin)
		if n == 0:
			break
		makedict(sys.stdin,sys.stdout,n)

Submission status: Runtime Error

Solution code:
while True:
	n=input()
	if n==0:
		break
	else:
		listb=[]
		listc=[]
		for a in range(1, n+1):
			b,c=map(int,raw_input().split())
		
			listb.append(b)
			listc.append(c)
 		m=input()
 		for d in range(1,m+1):
 			e=input()
 			if e in listb:
 				f=listb.index(e)
				print listc[f]
			else:
				print e

Submission status: Runtime Error

Solution code:
while True:
	n=input()
	if n==0:
		break
	else:
		listb=[]
		listc=[]
		for a in range(1, n+1):
			b,c=map(int,raw_input().split())
			listb.append(b)
			listc.append(c)
 		m=input()
 		listA=[]
 		for d in range(1,m+1):
 			e=input()
 			if e in listb:
 				f=listb.index(e)
				listA.append(listc[f])
			else:
				listA.append(e)
	Answer = "".join(map(str, listA))
	print Answer

Submission status: Runtime Error

Solution code:
while True:
	n=input()
	if n==0:
		break
	else:
		dic={}
		for a in range(1, n+1):
			b,c=map(int,raw_input().split())
			dic[b]=c
 		m=input()
 		listA=[]
 		for d in range(1,m+1):
 			e=input()
 			if e in dic:
 				listA.append(dic[e])
 			else:
				listA.append(e)
	Answer = "".join(map(str, listA))
	print Answer

Submission status: Runtime Error

Solution code:
while True:
	n=input()
	if n==0:
		break
	else:
		dic={}
		for a in range(1, n+1):
			b,c=map(int,raw_input().split())
			dic[b]=c
 		listA=[]
 		for d in range(1,input()+1):
 			e=input()
 			if e in dic:
 				listA.append(dic[e])
 			else:
				listA.append(e)
	print "".join(map(str, listA))

Submission status: Runtime Error

Solution code:
while(1):
  table, output = [], []
  table_number = input()
  string = ''
  for i in table_number:
    table.append(raw_input().split())
  string_number = input()
  for i in string_number:
    string = input()
    for table_element in table:
      if tabole_element[0] == string:
        string =table_element[1]
    output += string
  print output

Submission status: Runtime Error

Solution code:
while(1):
  table, output = [], []
  table_number = input()
  string = ''
  if table_number == 0:
    break
  for i in table_number:
    table.append(raw_input().split())
  string_number = input()
  for i in string_number:
    string = input()
    for table_element in table:
      if tabole_element[0] == string:
        string =table_element[1]
    output += string
  print output

Submission status: Runtime Error

Solution code:
while(1):
  table = {}
  output = ''
  table_number = input()
  if table_number == 0:
    break
  for i in table_number:
    table.append(raw_input().split())
  string_number = input()
  for i in string_number:
    string = input()
    for table_element in table:
      if tabole_element[0] == string:
        string =table_element[1]
    output += string
  print output

Submission status: Runtime Error

Solution code:
while(1):
  table = {}
  output = ''
  table_number = input()
  if table_number == 0:
    break
  for i in range(table_number):
    a, b = raw_input().split()
    table[a] = b
  string_number = input()
  for i in (string_number):
    string = input()
    for table_element in table:
      if tabole_element[0] == string:
        string =table_element[1]
    output += string
  print output

Submission status: Runtime Error

Solution code:
while(1):
  table = {}
  output = ''
  table_number = input()
  if table_number == 0:
    break
  for i in range(table_number):
    a, b = raw_input().split()
    table[a] = b
  string_number = input()
  for i in (string_number):
    string = input()
    if string in table:
      output += table[string]
    else:
      output += string
  print output

Submission status: Runtime Error

Solution code:
while(1):
  table = {}
  output = ''
  table_number = int(input())
  if table_number == 0:
    break
  for i in range(table_number):
    a, b = raw_input().split()
    table[a] = b
  string_number = int(input())
  for i in (string_number):
    string = input()
    if string in table:
      output += table[string]
    else:
      output += string
  print output

Submission status: Runtime Error

Solution code:
while(1):
  table = {}
  output = ''
  table_number = int(input())
  if table_number == 0:
    break
  for i in range(table_number):
    a, b = raw_input().split()
    table[a] = b
  string_number = int(input())
  for i in (string_number):
    string = raw_input()[0]
    if string in table:
      output += table[string]
    else:
      output += string
  print output

Submission status: Runtime Error

Solution code:
# -*- encoding:utf-8 -*-

convert_list = {}
result = []
n = int(raw_input())
for i in range(n):
    raw, converted = raw_input().rstrip().split(' ')
    convert_list[raw] = converted
n = int(raw_input())
for i in range(n):
    key = raw_input().rstrip()
    if (key in convert_list.keys()):
        result.append(convert_list[key])
    else:
        result.append(key)
print(''.join(result))

Submission status: Runtime Error

Solution code:
convert_list = {}
result = []
n = int(raw_input())
for i in range(n):
    raw, converted = raw_input().rstrip().split(' ')
    convert_list[raw] = converted
n = int(raw_input())
for i in range(n):
    key = raw_input().rstrip()
    if (key in convert_list.keys()):
        result.append(convert_list[key])
    else:
        result.append(key)
print(''.join(result))

Submission status: Runtime Error

Solution code:
# -*- encoding:utf-8 -*-

convert_list = {}
result = []
n = int(raw_input())
for i in range(n):
    raw, converted = raw_input().rstrip().split(' ')
    convert_list[raw] = converted
n = int(raw_input())
for i in range(n):
    key = raw_input().rstrip()
    result.append(convert_list.pop(key, key)
print(''.join(result))

Submission status: Runtime Error

Solution code:
answer=""
while True:
	try:
		N=int(input())
	except:
		break
	if answer!="":
		answer+="\n"
	b={}
	for i in range(N):
		a=input().split()
		b[a[0]]=a[1]
	M=int(input())
	
	ans=""
	for i in range(M):
		c=input()
		if c in b:
			ans+=b[c]
		else:
			ans+=c
	answer+=ans
print(answer)

Submission status: Runtime Error

Solution code:
conv_map = {}
str_result = ""
 
while True:
    conv_map = {}
    str_result = ""
    n=input()
    if n==0:
        break
 
    for idx in range(0, n):
        lst = raw_input().split()
        conv_map[lst[0]] = lst[1]
 
    m=input()
    tmp=""
    for idx in range(0, m):
        tmp=raw_input()
        str_result += conv_map.get(tmp, tmp)
 
    print str_result

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
import sys

class Converter:
    """????????????????????????????????????"""

    def __init__(self):
        self.table = {}
        for c in list("abcdefghijklmnopqrstuvwxyz"):
            self.table[c] = c
        for c in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
            self.table[c] = c
        for i in range(0, 10):
            self.table[str(i)] = str(i)

    def replace(self, before, after):
        self.table[before] = after

    def convert(self, key):
        return self.table[key]

    def debug_print(self):
        for v in self.table.values():
            print(v)

if __name__ == '__main__':
    rep_num = int(input())
    while rep_num !=0 :
        converter = Converter()
        for count in range(0, rep_num):
            data = input().split()
            converter.replace(data[0], data[1])

        for count in range(0, int(input())):
            print(converter.convert(input()), end="")
        print()
        rep_num = int(input())

Submission status: Runtime Error

Solution code:
class Converter:

    def __init__(self):
        self.table = {}
        for c in list("abcdefghijklmnopqrstuvwxyz"):
            self.table[c] = c
        for c in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
            self.table[c] = c
        for i in range(0, 10):
            self.table[str(i)] = str(i)

    def replace(self, before, after):
        self.table[before] = after

    def convert(self, key):
        return self.table[key]

    def debug_print(self):
        for v in self.table.values():
            print(v)

if __name__ == '__main__':
    rep_num = int(input())
    while rep_num !=0 :
        converter = Converter()
        for count in range(0, rep_num):
            data = input().split()
            converter.replace(data[0], data[1])

        for count in range(0, int(input())):
            print(converter.convert(input()), end="")
        print()
        rep_num = int(input())

Submission status: Runtime Error

Solution code:
class Converter:

    def __init__(self):
        self.table = {}
        for c in list("abcdefghijklmnopqrstuvwxyz"):
            self.table[c] = c
        for c in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
            self.table[c] = c
        for i in range(0, 10):
            self.table[str(i)] = str(i)

    def replace(self, before, after):
        self.table[before] = after

    def convert(self, key):
        return self.table[key]

    def debug_print(self):
        for v in self.table.values():
            print(v)

if __name__ == '__main__':
    rep_num = int(input())
    while rep_num !=0 :
        converter = Converter()
        for count in range(0, rep_num):
            data = input().split()
            converter.replace(data[0], data[1])

        output = ""
        for count in range(0, int(input())):
            output += converter.convert(input())
        print(output)
        rep_num = int(input())

Submission status: Runtime Error

Solution code:
class Converter:

    def __init__(self):
        self.table = {}
        self.reset()

    def reset(self):
        for c in list("abcdefghijklmnopqrstuvwxyz"):
            self.table[c] = c
        for c in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
            self.table[c] = c
        for i in range(0, 10):
            self.table[str(i)] = str(i)

    def replace(self, before, after):
        self.table[before] = after

    def convert(self, key):
        return self.table[key]

    def debug_print(self):
        for v in self.table.values():
            print(v)

if __name__ == '__main__':
    converter = Converter()
    rep_num = int(input())
    while rep_num !=0 :
        for count in range(0, rep_num):
            data = input().split()
            converter.replace(data[0], data[1])

        output = ""
        for count in range(0, int(input())):
            output += converter.convert(input())
        print(output)

        rep_num = int(input())
        converter.reset()

Submission status: Runtime Error

Solution code:
while True:
    x = int(input())
    if x == 0:
        break
    dcl = dict()
    for i in range(x):
        inp = list(map(str, input().split()))
        dcl[inp[0]] = inp[1]
    ans = ""
    x = int(input())
    y = str(input())
    for i in range(x):
        y = str(input())
        if y in dcl:
            ans += dcl[y]
        else:
            ans += y
    print(ans)

Submission status: Runtime Error

Solution code:
n1 = int(input())
A = []
B = []
for i in range(n):
 a, b = input().split()
 A.append(a)
 B.append(b)
n2 = int(input())
for i in range(n):
 x = input()
 if x in A:
  if type(x) is int:
   x = int(B[i])
  else:
   x = B[i]

 print("{0}".format(x))
print()

Submission status: Runtime Error

Solution code:
n1 = int(input())
A = []
B = []
for i in range(n1):
 a, b = input().split()
 A.append(a)
 B.append(b)
n2 = int(input())
for i in range(n2):
 x = input()
 if x in A:
  if type(x) is int:
   x = int(B[i])
  else:
   x = B[i]

 print("{0}".format(x))
print()

Submission status: Runtime Error

Solution code:
n = int(input())
A = []
B = []
for i in range(n):
 a, b = input().split()
 A.append(a)
 B.append(b)
n = int(input())
s = 0
for i in range(n):
 x = input()
 if x in A:
  ind = A.index(x)
  x = B[ind]
 s += x
print(s)

Submission status: Runtime Error

Solution code:
# coding: utf-8

def registerDictionaryFromTheNumberOf(counts):
    dictionary = {}
    for i in range(counts):
        key, value = input().split(" ")
        dictionary[key] = value
    return dictionary
        
def readCharacterBeforeConversionAsManyAs(counts):
    readString = ""
    for i in range(counts):
        readString += input()
    return readString
    
def convertCharactersByThe(dictionary, target):
    converted = ""
    for index in range(len(list(target))):
        if target[index] in dictionary:
            converted += dictionary[target[index]]
        else:
            converted += target[index]
    return converted
        
while True:
    dictionaryCounts = int(input())
    if dictionaryCounts == 0:
        break
    dictionary = registerDictionaryFromTheNumberOf(dictionaryCounts)gg
    original = readCharacterBeforeConversionAsManyAs(int(input()))
    converted = convertCharactersByThe(dictionary, original)
    print(converted)

Submission status: Runtime Error

Solution code:
import sys
while True:
	try:
		n????????¨=int(input())
		d????????¨ = [input().split() for i in range(n????????¨)]
		mData = int(input())
		dData = [input() for i in range(mData)]
	except EOFError:
		exit()

	dt={}
	for i in d????????¨:
		i1=i[0]
		i2=i[1]
		dt[i1]=i2

	for i in dData:
		if i in dt:
			sys.stdout.write(dt[i])
		else:
			sys.stdout.write(i)
	print()

Submission status: Runtime Error

Solution code:
import sys

n????????¨=int(input())
d????????¨=[input().split() for i in range(n????????¨)]
mData=int(input())
dData=[input() for i in range(mData)]

dt={}
for i in d????????¨:
	i1=i[0]
	i2=i[1]
	dt[i1]=i2

for i in dData:
	if i in dt:
		sys.stdout.write(dt[i])
	else:
		sys.stdout.write(i)
print()

Submission status: Runtime Error

Solution code:
import sys
while True:
	try:
		n????????¨=int(input())
		d????????¨ = [input().split() for i in range(n????????¨)]
		mData = int(input())
		dData = [input().strip() for i in range(mData)]
	except EOFError:
		exit()

	dt={}
	for i in d????????¨:
		i1,i2=i.split()
		dt[i1]=i2

	for i in dData:
		if i in dt:
			sys.stdout.write(dt[i])
		else:
			sys.stdout.write(i)
	print()

Submission status: Runtime Error

Solution code:
import sys
while True:
	try:
		n????????¨=int(input())
		d????????¨ = [input().split() for i in range(n????????¨)]
		mData = int(input())
		dData = [input().strip() for i in range(mData)]
	except EOFError:
		exit()

	dt={}
	for i in d????????¨:
		i1,i2=i
		dt[i1]=i2

	for i in dData:
		if i in dt:
			sys.stdout.write(dt[i])
		else:
			sys.stdout.write(i)
	print()

Submission status: Runtime Error

Solution code:
import sys
cin = sys.stdin
while True:
	try:
		n????????¨=int(cin.readline())
		d????????¨ = [cin.readline().split() for i in range(n????????¨)]
		mData = int(cin.readline())
		dData = [cin.readline().strip() for i in range(mData)]
	except EOFError:
		exit()

	dt={}
	for i in d????????¨:
		i1,i2=i
		dt[i1]=i2

	for i in dData:
		if i in dt:
			sys.stdout.write(dt[i])
		else:
			sys.stdout.write(i)
	print()

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    pre = ""
    post = ""
    for _ in range(n):
        l = map(str, input().split())
        pre += l[0]
        post += l[1]
    m = int(input())
    data = ""
    for _ in range(m):
        data += input()
    print(data.translate(str.maketrans(pre, post)))

Submission status: Runtime Error

Solution code:
while True:
	n = int(input())
	if n == 0:
		break
	change = dict()
	for i in range(n):
		f,t = input()
		change[f] = t
	ans = ''
	m = int(input())
	for j in range(m):
		s = input()
		if s in change:
			ans += change[s]
		else:
			ans += s
	print(ans)

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    x = {}
    for _ in range(n):
        a = input().split()
        x.update({a[0]: a[1]})
    m = int(input())
    y = []
    for _ in range(m):
        b = input()
        if x[b] :
            y.append(x[b])
        else:
            y.append(b)
    for i in range(m):
        print(y[i], end="")
    print()

Submission status: Runtime Error

Solution code:
import sys
while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    x = {}
    for _ in range(n):
        k,v = sys.stdin.readline().rstrip().split()
        dic[k] = v
    n = int(sys.stdin.readline().rstrip())
    y = []
    for _ in range(n):
        c = sys.stdin.readline().rstrip()
        if c in x:
            y.append(x[c])
        else:
            y.append(c)
    print(''.join(y))

Submission status: Runtime Error

Solution code:
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    x = {}
    for _ in range(n):
        k,v = sys.stdin.readline().rstrip().split()
        dic[k] = v
    n = int(sys.stdin.readline().rstrip())
    y = []
    for _ in range(n):
        c = sys.stdin.readline().rstrip()
        if c in x:
            y.append(x[c])
        else:
            y.append(c)
    print(''.join(y))

Submission status: Runtime Error

Solution code:
import sys

while True:
    n = int(input())
    if n == 0:
        break;
    x = {}
    for i in range(n):
        k,v = sys.stdin.readline().rstrip().split()
        x[k] = v
    y = []
    for i in range(int(input()):
        a = sys.stdin.readline().rstrip()
        if a in x:
            y.append(x[a])
        else:
            y.append(a)
    print(''.join(y))

Submission status: Runtime Error

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    d = {}
    for _ in range(n):
        a, b = input().split()
        d[a] = b
    m = int(input())
    tmp = [input().strip() for _ in range(int(input()))]
    ans = [d[a] if a in d.keys() else a for a in tmp]
    print("".join(ans))

Submission status: Runtime Error

Solution code:
inp = deque(input().replace('\t', '').split('\n'))
input = inp.popleft

while True:
    n = int(input())
    if n == 0:
        break
    table = dict()
    for i in range(n):
        f,t = input().split(' ')
        table[f] = t
    m = int(input())
    data = ''
    for j in range(m):
        s = input()
        if s in table:
            data += table[s]
        else:
            data += s
    print(data)

Submission status: Runtime Error

Solution code:
import sys
s=sys.stdin
r=readline()
while 1:
 n=int(s.r)
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=s.r.strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(s.readline()):
  e=s.r.strip()
  a+=d[e]if e in d else e
 print(a)

Submission status: Runtime Error

Solution code:
import sys
s=sys.stdin.readline
for n in iter(s,'0\n'):
 d={}
 for _ in[0]*int(n):
  k,v=s()[:-1].split()
  d[k]=v
 print(d.get(*[s()[0]]*2)for _ in[0]*int(s()),sep='')

Submission status: Runtime Error

Solution code:
d = dict()
n = int(input())
for i in range(n):
  a = input().split()
  d[a[0]] = d[a[1]]
m = int(input())
for i in range(m):
  c = input()
  c = d.get(c,c)
  print(c,)
print()

Submission status: Runtime Error

Solution code:
d = dict()
n = int(input())
for i in range(n):
  a = input().split()
  d[a[0]] = a[1]
m = int(input())
for i in range(m):
  c = input()
  c = d.get(c,c)
  print(c,)
print()

Submission status: Runtime Error

Solution code:
d = dict()
n = int(input())
for i in range(n):
  a = raw_input().split()
  d[a[0]] = a[1]
m = int(input())
for i in range(m):
  c = input()
  c = d.get(c,c)
  print(c,)
print()

Submission status: Runtime Error

Solution code:
d = dict()
n = int(input())
for i in range(n):
  a = input().split()
  d[a[0]] = d[a[1]]
m = int(input())
for i in range(m):
  c = raw_input()
  c = d.get(c,c)
  print(c,)
print()

Submission status: Runtime Error

Solution code:
d = dict()
n = int(input())
for i in range(n):
  a = raw_input().split()
  d[a[0]] = d[a[1]]
m = int(input())
for i in range(m):
  c = raw_input()
  c = d.get(c,c)
  print(c,)
print()

Submission status: Runtime Error

Solution code:

while True:
    n = input()

    if n != 0:
        
        table = [['',''] for i in range(n)]
        for i in xrange(n):
           table[i][0],table[i][1] = map(str, raw_input().split(' '))
        
        table0 = [table[i][0] for i in range(n)]
        table1 = [table[i][1] for i in range(n)]
        
        
        m = input()
        
        array = []
        for i in xrange(m):
           array.append(raw_input())
        
        array2 = [ '' for i in range(len(array))]
        
        for i in xrange(len(array)):
            if array[i] in table0:
                array2[i] = table1[table0.index(array[i])]
            else :
                array2[i] = array[i]
        
        
        for i in xrange(len(array2)-1):
            array2[i+1] = array2[i] + array2[i+1]
        
        print array2[-1]
        
    elif n == 0:
        break

Submission status: Runtime Error

Solution code:
import string

n = int(raw_input())
while n != 0:
	from = []
	to = []
	for i in xrange(n):
		l = raw_input().split()
		from.append(l[0])
		to.append(l[1])
	a = string.maketrans(''.join(from), ''.join(to))
	s = []
	for i in xrange(int(raw_input())):
		s.append(raw_input().strip())
	print s.translate(a)
	n = int(raw_input())

Submission status: Runtime Error

Solution code:
while True:
	dict = {}
	n = input()
	if n == 0:break
	for x in xrange(n):
		a, b = raw_input().split()
		dict[a] = b
	res = ""
	for x in xrange(input()):
		a = raw_input()
		if a in dict:
			res += dict[a]
		else
			res += a
	print a

Submission status: Runtime Error

Solution code:
out = []
append = out.append
cnt = int(raw_input())
while cnt > 0:
    trans = {}
    while cnt > 0:
        k,v = raw_input().split(' ')
        trans[k] = v
        cnt -= 1
    cnt = int(raw_input())
    ans = ''
    while cnt > 0:
        load = raw_input()
        if load in trans.keys(): load = trans[load]
        ans += load
        cnt -= 1
    print ans
    cnt = int(raw_iput())

Submission status: Runtime Error

Solution code:
out = []
append = out.append
cnt = int(raw_input())
while cnt > 0:
    trans = {}
    for i in range(cnt):
        k,v = raw_input().split()
        trans[k] = v.rsplit()
    leng = int(raw_input())
    ans = ''
    for i in range(leng):
        load = raw_input().rsplit()
        ans += (load in trans and trans[load]) or load
    print ans
    cnt = int(raw_input())