#include <bits/stdc++.h>
using namespace std;
const int nsize = 100005;
const int mo = 1000000009;
int fa[nsize];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) fa[i] = i;
    int a, b, sum = 0;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &a, &b);
      int x = find(a);
      int y = find(b);
      if (x == y) {
        sum = (sum * 2 + 1) % mo;
      } else
        fa[x] = y;
      printf("%d\n", sum);
    }
  }
  return 0;
}
