import java.util.Scanner;
public class Main {
    private static int[] parents;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Label:
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            if (n == 0) break;
            parents = new int[n + 1];
            int[] degrees = new int[n + 1];
            for (int i = 1; i <= n; i++) parents[i] = i;
            int m = sc.nextInt();
            while (m-- > 0) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                degrees[a]++;
                degrees[b]++;
                if (find(a) != find(b)) {
                    parents[find(a)] = find(b);
                }
            }
            for (int i = 1; i <= n; i++) {
                if (degrees[i] != 0 && find(i) != find(1) || degrees[i] % 2 != 0) {
                    System.out.println(0);
                    continue Label;
                }
            }
            System.out.println(1);
        }
    }
    private static int find(int x) {
        return x == parents[x] ? x : (parents[x] = find(parents[x]));
    }
}