Under construction

Still being built. Things may change

Dunglish

Time limit2sMemory limit512 MB

Summary
Given a Dutch sentence and per-word dictionary options marked correct or incorrect, output the unique translation and its status, or counts of correct and incorrect translations.
Level

Medium5 of 10

Topics
Implementation, Math, Combinatorics
Solved
No attempts yet

Problem

A Dutchman who is unsure of his English might say "I am in the war", even though no fighting is going on anywhere. The English sentence "I am confused" becomes "Ik ben in de war" in Dutch, and that Dutch sentence sounds a lot like the first one. Mix-ups like this one are funny (pun intended), and they also make it harder to work out what the speaker meant.

You are given a sentence in Dutch and a dictionary. The dictionary lists translations of single words, and every entry says whether it is the correct translation or a phonetic, incorrect one. A translation of the sentence replaces each word of the sentence by one of that word's dictionary entries, keeping the word order. Such a translation is correct when every word in it was translated correctly.

When the sentence has exactly one translation, report it and say whether it is correct. When it has more than one, count how many of the translations are correct and how many are incorrect.

Input

The first line contains an integer nn (1≤n≤201 \le n \le 20), the number of words in the Dutch sentence.

The second line contains the nn words of the Dutch sentence ss, separated by single spaces.

The third line contains an integer mm (1≤m≤1051 \le m \le 10^5), the number of entries in the dictionary.

Each of the next mm lines contains three strings dd, ee and cc: a Dutch word, its English translation, and the word "correct" if this is the correct translation or "incorrect" otherwise.

Every word consists of 1 to 20 lowercase letters. Every word of ss appears at least once as a Dutch word in the dictionary, no word appears more than 8 times as a Dutch word in the dictionary, and each combination of a Dutch word and an English word appears at most once.

Output

When ss has exactly one translation, print that translation on one line, then print "correct" or "incorrect" on the next line.

When ss has more than one translation, print the number of correct translations followed by a single space and the word "correct" on one line, then the number of incorrect translations followed by a single space and the word "incorrect" on the next line.

Examples2

  1. Example 1

    Input
    7
    als mollen mollen mollen mollen mollen mollen
    4
    als when correct
    mollen moles correct
    mollen destroy correct
    mollen mills incorrect
    
    Expected output
    64 correct
    665 incorrect
    
  2. Example 2

    Input
    5
    de zuigers zijn buiten werking
    6
    zijn are correct
    banaan banana correct
    de the correct
    zuigers suckers incorrect
    buiten out correct
    werking working incorrect
    
    Expected output
    the suckers are out working
    incorrect