n_cands = int(input()) cand_list = list(input().split()) m_voters = int(input()) vote_res = list(input().split()) # Use the candidate list to create a dictionary to store vote counts: vote_counts = {} for cand in cand_list: if cand not in vote_counts: vote_counts[cand] = 0 # Initialize the 'Invalid' category in the vote counts dictionary: vote_counts['Invalid'] = 0 for res in vote_res: if res in vote_counts: vote_counts[res] += 1 else: vote_counts['Invalid'] += 1 # Use .items() to iterate over each key-value pair for output printing: for key, value in vote_counts.items(): print(key + " : " + str(value))