 Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>


using namespace std;

const int N = 1e5 + 10;

int n, m;
bool isVal[N];
vector<int> graph[N];
vector<int> adj[N];
bool mark[N];
int h[N];
int jump[N];

void dfs(int v, int par = -1) 
{
    jump[v] = h[v];
    mark[v] = true;
    for (auto u: graph[v])
    {
        if (u == par)
        {
            continue;
        }
        if (!mark[u])
        {
            h[u] = h[v] + 1;
            dfs(u, v);
            jump[v] = min(jump[v], jump[u]);
        }
        else
        {
            jump[v] = min(jump[v], h[u] - 1);
        }
    }
}

void dfs2(int v)
{
    mark[v] = true;
    for (auto u: graph[v])
    {
        if (!mark[u] && isVal[u])
        {
            if (isVal[u] && isVal[v])
            {
                adj[u + 1].push_back(v + 1);
                adj[v + 1].push_back(u + 1);
            }
            dfs2(u);
        }
    }
}


int main() 
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) 
    {
        int u, v;
        cin >> u >> v;
        graph[u - 1].push_back(v - 1);
        graph[v - 1].push_back(u - 1);
    }
    for (int i = 0; i < n; i++)
    {
        if (!mark[i])
        {
            dfs(i);
        }
    }
    for (int i = 0; i < n; i++)
    {
        //cout << i << " " << jump[i] << " " << h[i] << endl;;
        if (jump[i] >= h[i])
        {
            isVal[i] = true;
        }
    }
    memset(mark, 0, sizeof mark);
    for (int i = 0; i < n; i++)
    {
        if (!mark[i] && isVal[i])
        {
            dfs2(i);
            adj[0].push_back(i + 1);
        }
    }


}