#include<iostream>
using namespace std;
int tree[105],s[105],root,mx=0,childs,M,N,son,father;
int main(){
cin>>N>>M;
for(int i=1;i<=M;++i){
cin>>father>>son;
tree[son]=father;
s[father]++; }
for(int i=1;i<=N;++i)
if(tree[i]==0){ root=i;
break;
}
for(int i=1;i<=N;++i){
if(s[i]>mx)mx=s[i],father=i; }
cout<<root<<endl;
cout<<father<<endl;
for(int i=1;i<=N;++i)if(tree[i]==father)cout<<i<<" ";
return 0;
}