Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
def convert(infile, outfile, n):
    dictionary = {}
    for i in range(n):
        key, val = infile.readline().split()
        dictionary[key]=val
    m = int(infile.readline())
    for j in range(m):
        x = infile.readline().split()[0]
        outfile.write(dictionary.get(x, x))
    print >> outfile
 
def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        convert(infile, outfile, n)
 
if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)