Explosive Materials

No attempts yetTime limit3sMemory limit256 MB

Problem

Erik is sending samples of nn kinds of material to his laboratory for a purity analysis. The kinds are numbered 1 to nn. He packs the samples into boxes of equal capacity. A box has capacity cc if it holds up to cc kinds of material.

Some materials react and explode, so they cannot go in the same box. Erik found that if putting kk kinds a1,,aka_1, \dots, a_k in one box explodes, then putting any two of them in one box explodes as well. He wrote down every pair that explodes, and the list has mm pairs.

Because every explosion comes from a pair, Erik wants to know whether two boxes of equal capacity are enough. All nn kinds must be split between the two boxes, and no two materials in the same box may form a pair from the list. If that is possible, what is the smallest capacity of a box?

Input

The first line contains the number of test cases TT (T20T \le 20).

The first line of each test case contains two integers nn and mm (1n10001 \le n \le 1000, 0mmin(n(n1)/2, 105432)0 \le m \le \min(n(n-1)/2,\ 105432)), the number of kinds of material and the number of pairs on the list. Each of the next mm lines contains two integers aa and bb (1a,bn1 \le a, b \le n, aba \ne b), meaning that material aa and material bb explode when they are put in the same box. No pair is listed twice.

Output

For each test case, print one integer on its own line. Print -1 if the materials cannot be sent in two boxes. Otherwise print the smallest capacity of a box.