Buggy python submission (verdict: Runtime Error):
dict1 = {}
dict2 = {}

while True:
	str = raw_input().split(",")
	
	if len(str[0]) == 0:
		break
	
	if dict1.has_key(str[0]):
		dict1[str[0]] = dict1[str[0]] + 1
	else:
		dict1[str[0]] = 1
	
while True:
	str = raw_input().split(",")
	
	if len(str[0]) == 0:
		break
	
	if dict2.has_key(str[0]):
		dict2[str[0]] = dict2[str[0]] + 1
	else:
		dict2[str[0]] = 1

list = dict2.keys()

for var in list:
	dict1[var] = dict1[var] + dict2[var]
	print var, dict1[var]

Fixed submission:
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]

Buggy python submission (verdict: Runtime Error):
dict1 = {}
dict2 = {}

while True:
	str = raw_input().split(",")
	
	if len(str[0]) == 0:
		break
	
	if dict1.has_key(str[0]):
		dict1[str[0]] = dict1[str[0]] + 1
	else:
		dict1[str[0]] = 1
	
while True:
	str = raw_input().split(",")
	
	if len(str[0]) == 0:
		break
	
	if dict2.has_key(str[0]):
		dict2[str[0]] = dict2[str[0]] + 1
	else:
		dict2[str[0]] = 1

list = sorted(dict2, reverse = True)
for var in list:
	dict1[var] = dict1[var] + dict2[var]
	print var, dict1[var]

Fixed submission:
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]

Buggy python submission (verdict: Runtime Error):
dict1 = {}
dict2 = {}

while True:
	str = raw_input().split(",")
	
	if len(str[0]) == 0:
		break
	
	if dict1.has_key(str[0]):
		dict1[str[0]] = dict1[str[0]] + 1
	else:
		dict1[str[0]] = 1
	
while True:
	try:
		str = raw_input().split(",")
		
		if dict2.has_key(str[0]):
			dict2[str[0]] = dict2[str[0]] + 1
		else:
			dict2[str[0]] = 1
		
	except:
		break

list = sorted(dict2, reverse = True)
for var in list:
	dict1[var] = dict1[var] + dict2[var]
	print var, dict1[var]

Fixed submission:
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]

Buggy python submission (verdict: Runtime Error):
dict1 = {}
dict2 = {}

while True:
	str = raw_input()
	if len(str[0]) == 0:
		break
	
	str.split(",")

	if dict1.has_key(str[0]):
		dict1[str[0]] = dict1[str[0]] + 1
	else:
		dict1[str[0]] = 1
	
while True:
	try:
		str = raw_input().split(",")
		
		if dict2.has_key(str[0]):
			dict2[str[0]] = dict2[str[0]] + 1
		else:
			dict2[str[0]] = 1
		
	except:
		break

list = sorted(set(dict1)&set(dict2), reverse = True)
for var in list:
	if(dict1[var] > 0 and dict2[var] > 0):
		print var, dict1[var] + dict2[var]

Fixed submission:
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]

Buggy python submission (verdict: Runtime Error):
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = dict1.keys()

for var in list:
	if dict1[var] > 0 and dict2[var] > 0:
		print var, dict1[var] + dict2[var]

Fixed submission:
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]