#sdpsgssolutions #Dictionary #Starter Problems 3 # Open the input and output files. inputFile = open("dictin.txt", "r") outputFile = open("dictout.txt", "w") # Read the input myInput = inputFile.readline().split() d = int(myInput[0]) w = int(myInput[1]) entry = 1 words = 1 # Create lists which contain the words in order iList = [] wList = [] # Write into lists for each language while entry <= d: myInput = inputFile.readline().split() iList.append(int(myInput[0])) wList.append(int(myInput[1])) entry = entry + 1 # Find the pages for each question while words <= w: myInput = int(inputFile.readline()) if myInput in iList: a = iList.index(myInput) b = wList[a] outputFile.write(str(b)+'\n') else: outputFile.write('C?'+'\n') words = words + 1 # Finally, close the input/output files. inputFile.close() outputFile.close()