#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 9;
int capital[100000];
int size[100000];
int reset[100000];
int monarch(int u) {
  int cnt = 0;
  while (capital[u] != u) {
    reset[cnt++] = u;
    u = capital[u];
  }
  for (int i = 0; i < cnt; i++) capital[reset[i]] = u;
  return u;
}
int main() {
  int n, k, a, b, c, d;
  int ans = 1;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    capital[i] = i;
    size[i] = 1;
  }
  for (int j = 0; j < k; j++) {
    scanf("%d %d", &a, &b);
    c = monarch(a);
    d = monarch(b);
    if (c != d) {
      if (size[c] > size[d]) {
        capital[d] = c;
        size[c] += size[d];
      } else {
        capital[c] = d;
        size[d] += size[c];
      }
    } else {
      ans = (ans << 1) % MOD;
    }
    printf("%d\n", ans - 1);
  }
  return 0;
}
