Woburn ECOO 1997 at Gramercy

Rearrange to See the Change

INPUT FILE: change.in
OUTPUT FILE: change.out

Consider all possible subsets of the letters from A to H. There are a lot of them. All possible subsets of size 2, for example, are

{AB, AC, AD, AE, AF, AG, AH, BC, BD, BE, BF, BG, BH, CD, CE, CF, CG, CH, DE, DF, DG, DH, EF, EG, EH, FG, FH, GH}

There are 28 of them. You will be given a list of some of these subsets and a list of integers in the range 1..8. You must determine is all the possible subsets of each of these sizes are in the list or not. If not, then you must print out how many subsets are missing. For example, if the input had only AB and BC then there are 26 subsets of size 2 missing.

INPUT

The first line will contain an integer n followed by n lines of subsets. After these n lines, on each follownig lnie you will be given an integer from 1 to 8. The data will be ended by a 0 on the final line.
Note: The letters in a subset can be in any order (ABC is the same as ACB, BAC, ...) and a subset may be repeated in the list.

OUTPUT
For each of the given integers print out "YES" if all possible subsets of that size are in the list. Otherwise print out the number of remaining possiblities not listed.

Sample Input File

13
CBA
CBA
BA
A
BCD
CB
C
B
D
E
F
G
H
1
2
8
0

Output for Sample Input

YES
26
1
Downloader failed! Response object 006~ASP 0159~Buffering Off~Buffering must be on.