B. Beautiful Spells
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There are summons, each with their own name, and spells to summon them. It is well-known that summons are quite picky and only respond to spells that are prefixes of their names.

You contracted a total of $$$n$$$ summons, the $$$i$$$-th of which has the name $$$s_i$$$; and there are $$$m$$$ magical spells in your spell book, the $$$i$$$-th of which is $$$t_i$$$. A new revolutionary casting technique allows you to summon two summons $$$i$$$ and $$$j$$$ with one spell $$$k$$$ if all of the following is true:

  • $$$t_k$$$ is a prefix of $$$s_i$$$;
  • $$$t_k$$$ is a prefix of $$$s_j$$$;
  • there exists no string longer than $$$t_k$$$ that is also a prefix of both $$$s_i$$$ and $$$s_j$$$.

Before the final fight with a big evil boss you want to determine how many pairs of summons can be summoned with a single spell. Note that one spell may fit the description for more than one pair of summons; in this case all of such pairs should be counted in the answer.

Input

The first line of input contains two integers $$$n$$$ and $$$m$$$ — the number of summons and spells respectively ($$$1 \le n, m \le 2 \cdot 10^5$$$).

In the $$$i$$$-th of the following $$$n$$$ lines, the name of the $$$i$$$-th summon is given as a string of lowercase Latin letters (from 'a' to 'z').

In the $$$j$$$-th of the following $$$m$$$ lines, the $$$j$$$-th spell is given — also a string of lowercase Latin letters.

The total length of strings from one set does not exceed $$$10^6$$$.

Output

Output a single integer: the number of pairs of summons that can be summoned with a single spell in your spellbook.

Example
Input
3 4
abacaba
aba
bbbb
a
aba
b
abacaba
Output
1