This page is still under construction.

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

Articulation points

Time limit1sMemory limit256 MB

Summary
Find and list in increasing order every vertex whose removal increases the number of connected components in an undirected graph.
Level

Medium4 of 10

Topics
DFS, Graph
Solved
No attempts yet

Problem

You are given an undirected graph. Write a program that finds every articulation point of the graph.

An articulation point is a vertex whose removal breaks the graph into two or more pieces. In other words, a vertex is an articulation point when deleting it increases the number of connected components. Deleting a vertex also deletes every edge attached to it.

Input

The first line contains the number of vertices VV and the number of edges EE. (1≤V≤100001 \le V \le 10000, 1≤E≤1000001 \le E \le 100000)

Each of the next EE lines contains two integers AA and BB, meaning that vertex AA and vertex BB are joined by an edge. Every edge is undirected.

The vertices are numbered from 1 to VV. The given graph is not necessarily connected.

Output

Print the number of articulation points on the first line.

On the second line, print the numbers of the articulation points in increasing order, separated by one space. If there is no articulation point, leave the second line empty.

Examples4

  1. Example 1

    Input
    7 7
    1 4
    4 5
    5 1
    1 6
    6 7
    2 7
    7 3
    
    Expected output
    3
    1 6 7
    
  2. Example 2

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

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

    Input
    5 5
    1 2
    2 3
    3 4
    4 5
    5 1
    
    Expected output
    0