#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<functional>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int maxn =1005;
const int inf = 1<<30;//0x7f;
typedef __int64 LL;
int n,m;
int p[maxn],in[maxn];;
int find( int x )
{
return p[x] == x?x:p[x] = find(p[x]);
}
void merge( int a,int b )
{
int x = find(a);
int y = find(b);
if( x != y )
p[y] = x;
}
void init()
{
for( int i = 1; i <= n; i ++ )
p[i] = i,in[i] = 0;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
int u,v;
while( scanf("%d",&n) != EOF,n )
{
scanf("%d",&m);
init();
for( int i = 1; i <= m; i ++ ){
scanf("%d%d",&u,&v);
merge(u,v);
in[u] ++; in[v] ++;
}
for( int i = 1; i <= n; i ++ )
find(i);
int flag = 1;
for( int i = 1; i <= n; i ++ ){
if( p[i] != p[1] || in[i]%2 ){
flag = 0; break;
}
}
if( flag )
puts("1");
else
puts("0");
}
return 0;
}