The first line contains an integer n (2≤n≤26).
Each of the next n lines contains one premise. Every premise has the form a is b, where a and b are two different lowercase letters. The premise a is b means "all a are b" and never means "all b are a". No letter is the subject of two premises, so a cannot be b and c at the same time. Two different letters a and b can both be c.
Line n+2 contains an integer m (1≤m≤10). Each of the next m lines contains one conclusion in the same format as a premise.