# Nature

In nature, there are alimentary chains. At the basis of this chain, we generally have the vegetals. Small animals eat those vegetals and bigger animals eat the smaller. There can be cycles in the chain, as when some animal dies he starts a decomposition process which will transform its body into minerals that are a source of energy for the vegetals. In this problem you will have to find the largest alimentary chain for a given group of creatures. You can consider that if A is predator of B then they are in the same chain. Input The input file contains several input sets. The description of each set is given below: Each set starts with two integers C (1 ≤ C ≤ 5000), the number of creatures, and R (0 ≤ R ≤ 5000), the number of relations. Follow C lines with the names of the creatures, each consisting of lower case letters (a, b, ..., z). No name is longer than 30 letters. Then there will be R lines describing the relations. Each line will have 2 names of creatures, meaning that the second creature is a predator of the first one. You can assume that no creature is a predator of himself. Input is terminated by a set where C = R = 0. This set should not be processed. There is a blank line beteween two input sets. Output For each input set produce one line of output, the size of the largest alimentary chain. Sample Input 52 caterpillar bird horse elefant herb herb caterpillar caterpillar bird 00 Sample Output 3