UVa Panel Discussion

The UVa online judge team is arranging a panel discussion for the next ACM-ICPC World Finals event in Orlando, Florida. They want that three or four of the contestants take part in the panel and as they have about 300 persons for selecting such a little group, they have decided to put some restrictions in order to reduce the number of possibilities. After thinking about several options, they finally propose that in case the number of contestants to choice be 3, all of them must be of the same country or from three different countries; and in case the number be 4, at least three of them will be of the same country or must be from at least three different countries. Could you help them to calculate the number of different selections they can make following the restrictions above. Input The input file contains several test cases; each of them consists of two lines. The first contains two integers N and M separated by one space. N (3 ≤ N ≤ 300) is the number of contestants and M (1 ≤ M ≤ 50) the total number of different countries. The second line consists of N integers between 1 and M, separated by a space, representing the country each contestant is from (It is not necessary that contestants will be from M countries). Last line of the input will contain two zeroes and it won’t be processed. Output For each input case write, in a line by itself, two integers separated by a space. The first integer being be the number of ways to select a group of three people, and the second the number of ways to do it of four people. Sample Input 35 542 53 31322 10 10 1 8 9 1 6 7 3 4 10 4 00 Sample Output 10 44 104 209