| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
|---|
| Days | Su | Mo | Tu | We | Th | Fr | Sa | Su | Mo | Tu | We | Th | Fr | Sa |
| Party 1 | x | x | x | x | ||||||||||
| Party 2 | x | x | x | |||||||||||
| Party 3 | x | |||||||||||||
| Hartals | 1 | 2 | 3 | 4 | 5 |
The simulation above shows that there will be exactly 5 hartals (on days 3, 4, 8, 9 and 12) in 14 days. There will be no hartal on day 6 since it is a Friday. Hence we lose 5 working days in 2 weeks.
In this problem, given the hartal parameters for several political parties and the value of N , your job is to determine the number of working days we lose in those N days.
The first line of the input consists of a single integer T giving the number of test cases to follow.
The first line of each test case contains an integer N (7 ≤ N ≤ 3650) giving the number of days over which the simulation must be run. The next line contains another integer P (1 ≤ P ≤ 100) representing the number of political parties in this case. The ith of the next P lines contains a positive integer hi (which will never be a multiple of 7) giving the hartal parameter for party i (1 ≤ i ≤ P ).
For each test case in the input output the number of working days we lose. Each output must be on a separate line.