判断无向图的欧拉回路。。。就两个条件:1.图连通,2.度全为偶数。。。。
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <time.h>
#define maxn 1005
#define maxm 200005
#define eps 1e-7
#define mod 1000000007
#define INF 0x3f3f3f3f
#define PI (acos(-1.0))
#define lowbit(x) (x&(-x))
#define mp make_pair
#define ls o<<1
#define rs o<<1 | 1
#define lson o<<1, L, mid
#define rson o<<1 | 1, mid+1, R
#define pii pair<int, int>
#pragma comment(linker, "/STACK:16777216")
typedef long long LL;
typedef unsigned long long ULL;
//typedef int LL;
using namespace std;
LL qpow(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base;base=base*base;b/=2;}return res;}
LL powmod(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base%mod;base=base*base%mod;b/=2;}return res;}
// head
int du[maxn];
int f[maxn];
int c[maxn];
int n, m;
int find(int x)
{
return x == f[x] ? f[x] : find(f[x]);
}
void merge(int a, int b)
{
int aa = find(a), bb = find(b);
if(aa != bb) {
f[aa] = bb;
c[bb] += c[aa];
}
}
void read()
{
int u, v;
for(int i = 1; i <= n; i++) f[i] = i;
for(int i = 1; i <= n; i++) c[i] = 1;
for(int i = 1; i <= n; i++) du[i] = 0;
scanf("%d", &m);
while(m--) {
scanf("%d%d", &u, &v);
merge(u, v);
du[u]++, du[v]++;
}
}
void work()
{
int cnt = 0, ok = 0;
if(c[find(1)] != n) ok = 1;
for(int i = 1; i <= n; i++) if(du[i] % 2) ok = 1;
if(!ok) printf("1\n");
else printf("0\n");
}
int main()
{
while(scanf("%d", &n), n) {
read();
work();
}
return 0;
}