This page is still under construction.

Parts of this page are still being built. What you see may change.

The Bad Scientist

Time limit1sMemory limit128 MB

Summary
Given a graph of contradictions, delete at most k vertices to remove all edges and report the smallest such set size, or IMPOSSIBLE.
Level

Hard8 of 10

Topics
Graph, Brute force, Combinatorics, Backtracking
Solved
No attempts yet

Problem

Sanggeun is a scientist who fabricates his experimental results. He has always tampered with them so carefully that for the past several years nobody has ever caught him. But after going unsuspected for so long, Sanggeun has grown careless with his forgeries.

As a result, his latest paper contains theories that contradict one another. To remove these contradictions, Sanggeun decides to delete some of the theories from the paper. Whenever two theories contradict each other, deleting at least one of the two makes that contradiction disappear.

Meanwhile, Sanggeun's colleague Seonjin has watched all of his experiments over the years. Because of that, there is a limit to how many theories Sanggeun can delete before Seonjin grows suspicious.

Input

The first line contains the number of test cases TT. (1≤T≤1001 \le T \le 100)

Each test case is given as follows.

  • The first line contains the number of theories nn in the paper. (1≤n≤501 \le n \le 50)
  • The second line contains kk, the maximum number of theories that can be deleted without arousing suspicion. (0≤k≤160 \le k \le 16)
  • The third line contains mm, the number of contradicting pairs of theories. (0≤m≤n(n−1)20 \le m \le \frac{n(n-1)}{2})
  • Each of the next mm lines contains two theories xix_i and yiy_i that contradict each other. (1≤xi<yi≤n1 \le x_i < y_i \le n)

The theories are numbered from 11 to nn, and no pair of theories is given more than once.

Output

For each test case, print on its own line the minimum number of theories that must be deleted so that the paper contains no contradictions.

If that minimum exceeds kk, so that suspicion cannot be avoided, print IMPOSSIBLE instead.

Examples2

  1. Example 1

    Input
    2
    5
    5
    2
    1 3
    2 3
    3
    1
    3
    1 2
    2 3
    1 3
    
    Expected output
    1
    IMPOSSIBLE
    
  2. Example 2

    Input
    1
    1
    0
    0
    
    Expected output
    0