cho.sh
Notes
Loading...

Picnic

Time limit

2s

Memory limit

128 MB

Problem

Among N students numbered from 1 to N, exactly K students must be chosen for a picnic. To avoid conflicts, every pair of chosen students must be friends. In other words, the chosen K students must form a group in which all pairs are connected by a friendship relation.

Given F friendship relations, find and print the student numbers of one valid group of K students.

Input

The first line contains three integers K, N, and F separated by spaces. (1 ≤ K ≤ 62, K ≤ N ≤ 900, 1 ≤ F ≤ 5,600)

Each of the next F lines contains the numbers of two students who are friends. Friendship is bidirectional. The same friendship relation is never given more than once.

Output

If no valid group of K students exists, print -1.

Otherwise, print the selected student numbers in increasing order, one number per line. If multiple valid groups exist, print the lexicographically smallest increasing sequence of student numbers.