#include<iostream> #include<cstring> using namespace std; int map[1111][1111]; int d[1111]; int fa[1111]; int n,m; //int d[1111]; int getfa(int x) { while(fa[x]!=x) x=fa[x]; return x; } void un(int u,int v) { int x=getfa(u); int y=getfa(v); fa[x]=y; } bool f() { int sum=0; for(int i=1;i<=n;i++) if(fa[i]==i) sum++; if(sum>1) return false; return true; } int main() { int i; while(cin>>n&&n) { cin>>m; sizeof(map,0,sizeof(map)); memset(d,0,sizeof(d)); for(i=1;i<=n;i++) fa[i]=i; for(i=1;i<=m;i++) { int x,y; cin>>x>>y; map[x][y]=map[y][x]=1; d[x]++; d[y]++; un(x,y); } if(!f()) { cout<<'0'<<endl; continue; } for(i=1;i<=n;i++) if(d[i]%2!=0) break; if(i<=n) cout<<'0'<<endl; else cout<<'1'<<endl; } return 0; }