Under construction

Still being built. Things may change

Save the Earth!

Time limit2sMemory limit1024 MB

Summary
Find a sequence of shuttle trips that moves the leader and all superheroes to Earth without leaving a conflicting pair alone on either planet, or report -1.
Level

Hard8 of 10

Topics
Bit manipulation, BFS, Graph
Solved
No attempts yet

Problem

A squad of superheroes is rushing to help the defenders of Earth in the battle against Thanos. The superheroes are currently on Titan, and they have only one space shuttle. The shuttle holds kk passengers and one pilot. The squad consists of one wise leader and nn other superheroes. Some pairs of superheroes dislike each other, may quarrel, or even harm one another. However, when the leader is nearby, superheroes never conflict, because the leader strictly stops it.

The leader will pilot the shuttle. The leader wants to know whether all superheroes can be transported to Earth. The transport works as follows:

  • At most kk superheroes board the shuttle together with the leader. Among the superheroes left on Titan, there must be no conflicting pair, or disastrous consequences may follow.
  • The shuttle flies to Earth. During the flight, the superheroes on board are next to the leader, so they do not fight.
  • On Earth, all superheroes on the shuttle get off. Among the superheroes now on Earth, a conflicting pair may exist. They do not fight, because the leader is nearby.
  • At most kk superheroes board the shuttle. Among the superheroes left on Earth, there must be no conflicting pair.
  • The shuttle flies to Titan.
  • On Titan, all superheroes on the shuttle get off. Among the superheroes on Titan at that moment, a conflicting pair may exist.

These steps repeat in a cycle until all superheroes and the leader are on Earth. The leader may fly between planets without any superheroes if needed. If a planet has no leader, it must have no conflicting pair. There are no other restrictions on conflicting pairs.

You are given the list of conflicting pairs. Help the leader find a sequence of actions that transports all superheroes to Earth, or report that it is impossible. Minimizing the number of flights is not required. However, the leader wants a plan with at most 100 000100\,000 flights. It can be proven under these constraints that if a way to deliver everyone to Earth exists, a way with at most 100 000100\,000 flights also exists.

Input

The first line contains three integers nn, mm, and kk: the number of superheroes, the number of conflicting pairs, and the number of superheroes that fit into the shuttle (1≤n≤151 \le n \le 15, 0≤m≤n⋅(n−1)/20 \le m \le n \cdot (n - 1) / 2, 1≤k≤151 \le k \le 15).

Each of the next mm lines contains a pair of integers aia_i, bib_i, the numbers of superheroes that conflict (1≤ai,bi≤n1 \le a_i, b_i \le n, ai≠bia_i \neq b_i).

Each pair of superheroes appears at most once. If the input contains the pair aia_i, bib_i, then the pair bib_i, aia_i does not appear.

Output

If it is impossible to transport all superheroes and the leader to Earth, print −1-1 on a single line.

Otherwise, print on the first line the integer tt, the number of flights the shuttle makes so that all superheroes and the leader end up on Earth (t≤100 000t \le 100\,000). On each of the next tt lines, print the list of superheroes on the shuttle during the ii-th flight. Begin the line with qiq_i, the size of the list, followed by qiq_i distinct numbers, the numbers of the superheroes on the shuttle during that flight.

Hint

Flight numberOn TitanIn flightOn Earth
-1, 2, 3
11, 32→\rightarrow
-1, 32
21, 3←\leftarrow2
-1, 32
313→\rightarrow2
-12, 3
412←\leftarrow3
-1, 23
521→\rightarrow3
-21, 3
62←\leftarrow1, 3
-21, 3
72→\rightarrow1, 3
-&1, 2, 3

Examples1

  1. Example 1

    Input
    3 2 1
    1 2
    2 3
    
    Expected output
    7
    1 2
    0
    1 3
    1 2
    1 1
    0
    1 2