#include <bits/stdc++.h>
int djs[100005];
int find(int now) { return djs[now] == now ? now : djs[now] = find(djs[now]); }
bool set(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return 0;
  djs[a] = b;
  return 1;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) djs[i] = i;
  int ans = 1;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    if (!set(a, b)) ans = (ans * 2) % 1000000009;
    printf("%d\n", (ans - 1 + 1000000009) % 1000000009);
  }
}
