**119 人解决**，155 人已尝试。

**179 份提交通过**，共有 453 份提交。

**3.1** EMB 奖励。

**单点时限: **2.0 sec

**内存限制: **256 MB

Children are used to playing with special cubes with letters written on the cubes' faces. The goal of the game is to compose words using such cubes. If you want to compose the word “DOG”, you must find 3 cubes, one containing the letter 'D', one containing the letter 'O', and one containing the letter 'G', and orient them so the proper letters are facing upward.

You are also given a some words, each element of which contains a word that you would like to spell out using the cubes.

There are several test cases,each test case begins with two numbers N(1<=N<=50) and M(1<=M<=50).the second line contains N string,the i-th string shows the uppercase letters(between 2 and 50,inclusive) on the i-th cube.The third line contains the M words.Each element of words will contain between 2 and 50 uppercase letters, inclusive.

Output the words' number that can be composed using the given cubes in ascending order. If no words' number that can be composed output -1.

Input

5 3 ABCDEF DEFGHI OPQRST ZZZZZZ YYYYYY CAT DOG PIZZA 6 7 ABCDEF DEFGHI OPQRST MNZLSA QEIOGH IARJGS DOG CAT MOUSE BIRD CHICKEN PIG ANIMAL

Output

1 0 1 3 5

Case 1:

We can form the word “DOG” using ‘D’ from the first cube, ‘O’ from the third and ‘G’ from the second. Note that if we had used the second cube to get ‘D’ instead, we would be missing a ‘G’.

**119 人解决**，155 人已尝试。

**179 份提交通过**，共有 453 份提交。

**3.1** EMB 奖励。

**创建**: 11 年，9 月前.

**修改**: 2 年，2 月前.

**最后提交**: 1 年前.

**来源**: N/A

题目标签