아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Special Cycle

시간 제한7초메모리 제한2048 MB

요약
무방향 그래프에서 특별 간선마다 사이클에 포함되거나 양 끝점이 모두 사이클 밖에 있는 단순 사이클을 찾는다.
난이도

보통10점 중 7점

유형
그래프, DFS, 백트래킹
정답자
아직 제출이 없습니다

문제

You are given a simple undirected graph with no self-loops or multiple edges. Some of the edges are marked as Special.

Your task is to find a simple cycle where, for each Special edge, that edge either belongs to the cycle or neither of its endpoints touch the cycle. The cycle is not allowed to repeat vertices. Output any solution, or report that none exist.

입력

The first line of input contains three integers nn (2≤n≤1502 \le n \le 150), mm (1≤m≤n⋅(n−1)21 \le m \le \frac{n \cdot (n-1)}{2}) and kk (1≤k≤m1 \le k \le m), where nn is the number of nodes in the graph, mm is the number of edges, and kk is the number of edges that are Special. The nodes are numbered 11 through nn.

Each of the next mm lines contains two integers aa and bb (1≤a<b≤n1 \le a < b \le n), denoting an undirected edge between nodes aa and bb. All edges are distinct. The first kk edges are the Special edges.

출력

Output an integer denoting the length of the found cycle on one line. On subsequent lines, output the vertices of the cycle in order around the cycle, one per line. If no such cycle exists, simply output −1-1.

예제2

  1. 예제 1

    입력
    8 10 3
    1 2
    4 5
    7 8
    2 3
    3 4
    1 4
    5 6
    6 7
    5 8
    3 8
    
    예상 출력
    8
    1
    4
    5
    6
    7
    8
    3
    2
    
  2. 예제 2

    입력
    4 6 3
    1 2
    1 3
    1 4
    2 3
    3 4
    2 4
    
    예상 출력
    -1