//HDU 1878 欧拉回路
//非并查集写法,欧拉回路的限制条件:1.应该是一个一个连通图
// 2.每一个点应该是有偶数个点和它相连。二者都满足就是一个欧拉回路
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1100
int n, m;
int maps[N][N], vis[N], visit[N];
void DFS(int x)
{
visit[x]=1;
for(int i=1; i<=n; i++)
{
if(maps[x][i]&&visit[i]==0)
DFS(i);
}
}
int main()
{
int a, b;
while(scanf("%d", &n), n)
{
scanf("%d", &m);
memset(maps, 0, sizeof(maps));
memset(vis, 0, sizeof(vis));
memset(visit, 0, sizeof(visit));
for(int i=0; i<m; i++)
{
scanf("%d%d", &a, &b);
if(maps[a][b]==0)
{
vis[a]++;
vis[b]++;
}
maps[a][b]=maps[b][a]=1;
}
int flag=0, flag1=0;
DFS(1);
for(int i=1; i<=n; i++)
if(visit[i]==0)
{
flag=1;
break;
}
for(int i=1; i<=n; i++)
if(vis[i]%2==1)
{
flag1=1;
break;
}
if(flag==0&&flag1==0)
printf("1
");
else
printf("0
");
}
return 0;
}