1 #include <iostream>
2
3 using namespace std;
4
5 int find(int map[],int x);
6
7 int main()
8 {
9 int map[1005],degree[1005],count1,count2;
10 int N, M,i,x,y;
11 while(cin>>N && N>0) {
12 cin>>M;
13 for(i=0;i<=N;i++) {
14 map[i]=i;
15 degree[i]=0;
16 }
17 for(i=0;i<M;i++) {
18 cin>>x>>y;
19 degree[x]++;
20 degree[y]++;
21 map[find(map,y)]=map[find(map,x)];
22 }
23 count1=count2=0;
24 for(i=1;i<=N;i++) {
25 if(map[i]==i) count1++;
26 if(degree[i]==0 || degree[i]%2==1) count2++;
27 }
28 if(count1==1 && count2==0) cout<<1<<endl;
29 else cout<<0<<endl;
30 }
31 return 0;
32 }
33
34 int find(int map[], int x) {
35 return map[x]==x ? x : find(map,map[x]) ;
36 }