#include<bits/stdc++.h>
using namespace std;
#define rd(i,n) for(int i=0;i<n;i++)
#define rp(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define st string
#define vt vector
#define pb push_back
//#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N=500005;
int n,m,a[N],b[N],c;
int dfn[N],low[N],ti;
vt<int>G[N];
vt<int>ans;
inline void dfs(int x,int p){
dfn[x]=low[x]=++ti;
int cnt=(p!=0);
bool flag=0;
for(auto i:G[x])if(j!=p){
if(!dfn[i]){
cnt++;
dfs(i,x);
low[x]=min(low[x],low[i]);
if(i&&low[i]>=dfn[x])flag=1;
}else{
low[x]=min(low[x],dfn[i]);
}
}
if(cnt>=2)ans.pb(x);
else if(flag)ans.pb(x);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
rp(i,m){
cin>>a[i]>>b[i];
G[a[i]].pb(b[i]);
G[b[i]].pb(a[i]);
}
rp(i,n)if(!dfn[i])dfs(i,0);
sort(ans.begin(),ans.end());
ans.erase(unique(ans.begin(),ans.end()),ans.end());
for(auto i:ans)cout<<i<<endl;
return 0;
}
//Rain Rain Rain