Problem:
D - Medical Inspection

Problem Statement

The government has declared a state of emergency due to the MOFU syndrome epidemic in your country. Persons in the country suffer from MOFU syndrome and cannot get out of bed in the morning. You are a programmer working for the Department of Health. You have to take prompt measures.

The country consists of n islands numbered from 1 to n and there are ocean liners between some pair of islands.
The Department of Health decided to establish the quarantine stations in some islands and restrict an infected person's moves to prevent the expansion of the epidemic.
To carry out this plan, there must not be any liner such that there is no quarantine station in both the source and the destination of the liner.
The problem is the department can build at most K quarantine stations due to the lack of budget.

Your task is to calculate whether this objective is possible or not.
And if it is possible, you must calculate the minimum required number of quarantine stations.

Input

The test case starts with a line containing three integers N (2 \leq N \leq 3{,}000), M (1 \leq M \leq 30{,}000) and K (1 \leq K \leq 32).
Each line in the next M lines contains two integers a_i (1 \leq a_i \leq N) and b_i (1 \leq b_i \leq N). This represents i-th ocean liner connects island a_i and b_i.
You may assume a_i \neq b_i for all i, and there are at most one ocean liner between all the pairs of islands.

Output

If there is no way to build quarantine stations that satisfies the objective, print "Impossible" (without quotes). Otherwise, print the minimum required number of quarantine stations.

Sample Input 1

3 3 2
1 2
2 3
3 1

Output for the Sample Input 1

2

Sample Input 2

3 3 1
1 2
2 3
3 1

Output for the Sample Input 2

Impossible

Sample Input 3

7 6 5
1 3
2 4
3 5
4 6
5 7
6 2

Output for the Sample Input 3

4

Sample Input 4

10 10 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

Output for the Sample Input 4

4

Solution in Ruby (judge verdict: Wrong Answer)

n, m, k = gets.split.map(&:to_i)
g = [0] * n

m.times do
	i, j = gets.split.map(&:to_i)
	i -= 1
	j -= 1
	g[i] |= (1 << j)
	g[j] |= (1 << i)
end

def f(graph, k)
	i = (0..graph.size-1).max_by {|i| graph[i].to_s(2).count(?1) }
	return k >= 0 ? k : -Float::INFINITY if graph[i] == 0
	return -Float::INFINITY if k <= 0

	g = graph.dup
	(0..graph.size-1).each do |j|
		g[j] -= (1 << i) if g[j][i] == 1
	end
	g[i] = 0
	max = f(g, k-1)

	g = graph.dup
	d = g[i].to_s(2).count(?1)
	return max if d > k

	mask = g[i] | (1 << i)
	(0..graph.size-1).each do |j|
		if mask[j] == 1
			g[i] = 0
		else
			g[i] -= g[i] & mask
		end
	end
	ret = f(g, k-d)

	return ret > max ? ret : max
end

loop do
	i = g.index {|x| x.to_s(2).count(?1) <= 1}
	break if !i
	if g[i].to_s(2).count(?1) == 0
		g.delete_at(i)
		g.map! do |x|
			l = (x >> i + 1)
			r = x & ((1 << i) - 1)
			(l << i) | r
		end
	else
		k -= 1
		(0..g.size-1).each do |j|
			g[j] -= (1 << i) if g[j][i] == 1
		end
		g[i] = 0
	end
end

c = f(g, k)
puts c >= 0 ? k - c : 'Impossible'