This page is still under construction.

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

Meeting

Time limit1sMemory limit1024 MB

Summary
Given a bipartite like-graph between N men and N women, find a subset of men whose neighborhood (women liking at least one chosen man) is strictly smaller than the subset size, or report that no such subset exists.
Level

Medium7 of 10

Topics
Graph, Union-find, Greedy, Implementation
Solved
No attempts yet

Problem

There are NN men and NN women who signed up for a meeting arranged by Gukryeol, hoping to meet a romantic partner.

We are given MM pairs of a man and a woman who like each other. Gukryeol wants to run the meeting by picking an arbitrary subset of the men who signed up. Seeing the men he picked, every woman who likes at least one of them joins the meeting. If the number of men at the meeting is less than or equal to the number of women, the meeting goes smoothly. If instead there are more men, the meeting cannot go smoothly. In the example in the figure, when the 2nd man and the 3rd man are picked, the only woman who likes either of them is the 2nd woman, and since there are more men, the meeting cannot go smoothly.

Gukryeol is the one arranging this meeting, but he comes from an undefeated singles squad and does not want others to do well, so he wants to prevent the meeting from going smoothly. Given the like relationships between men and women, pick the men so that the meeting does not go smoothly.

Input

The first line gives NN and MM. (1≤N≤5001 \le N \le 500, 0≤M≤N20 \le M \le N^2)

The next MM lines each give two integers uu and vv. This means the uu-th man and the vv-th woman like each other. Each man-woman relationship is given at most once.

Output

If you can pick men so that the meeting cannot go smoothly, print the number of men to pick on the first line. On the next line, print the indices of the men to pick. If there are several valid ways, print any of them.

If the meeting can go smoothly no matter how the men are picked, print -1 on the first line.

Examples2

  1. Example 1

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

    Input
    3 9
    1 1
    1 2
    1 3
    2 1
    2 2
    2 3
    3 1
    3 2
    3 3
    
    Expected output
    -1