Long ago there were two languages, Namgyu and Jaehyeok. At some point a language halfway between them, called Sanghak, came into being.
A Sanghak word is built as follows.
For example, from the Namgyu word abc and the Jaehyeok word de you can make ae, ade, abe, abde, abce, and abcde, but you cannot make bce, ace, or abc.
It does not matter whether the resulting word actually means anything. Given a Namgyu dictionary and a Jaehyeok dictionary, determine how many distinct Sanghak words can be formed. For instance, with Namgyu words ab, abc and Jaehyeok words cd, d, the word abcd can be formed in two different ways, but since it is the same word it is counted only once.
The input consists of several test cases and ends with a line 0 0.
The first line of each test case contains the number of Namgyu words $P$ and the number of Jaehyeok words $S$. ($1 \le P, S \le 1000$)
The next $P$ lines each contain one Namgyu word, and the following $S$ lines each contain one Jaehyeok word. Every word consists of between $1$ and $1000$ lowercase English letters. No word appears twice within the same language, and the total length of all words in one language is at most $10^5$.
For each test case, print on its own line the number of distinct Sanghak words that can be formed.