#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define N 3000000
unsigned long long a[N],b[N];
unsigned long long f[1005][1005],ans[1005][1005];
int T,n,Q;
unsigned long long read()
{
    unsigned long long ans=0,f_id=1;
    char ch=getchar();
    while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if (ch=='-') f_id=-1,ch=getchar();
    while (ch>='0'&&ch<='9') ans=ans*10+ch-'0',ch=getchar();
    return ans*f_id;
}
unsigned long long outgs,outj[100];
void write(unsigned long long x)
{
    if (x==0)
    {
        putchar('0');
        return ;
    }
    if (x<0) putchar('-'),x=-x;
    outgs=0;
    while (x)
    {
        outgs++;
        outj[outgs]=x%10;
        x/=10;
    }
    for (int i=outgs;i;--i) putchar(outj[i]+'0');
}
void trying(ll x)
{
    if (x==n+m+1)
    {
        for (int i=1;i<=n;++i) f[i]=0;
        for (int i=1;i<=n;++i) if (vis[i])
        {
            f[i]=1;
            break;
        }
        for (int i=1;i<=m;++i)
        for (int j=1;j<=m;++j)
        {
            if (vis[j+n])
            {
                if (f[b[j+n]][1]) f[b[j+n]][2];
                if (f[b[j+n]][2]) f[b[j+n]][1];
            }
        }
        for (int i=1;i<=n;++i)
            return ;
    }
    vis[x]=1;
    trying(x+1);
    vis[x]=0;
}
int main()
{
    freopen("barrack.in","r",stdin);freopen("barrack.out","w",stdout);
	n=read(),m=read();
	for (int i=1;i<=m;++i) b[i][1]=read(),b[i][2]=read();
	trying(1);
    return 0;
}


















