#include <bits/stdc++.h>
using namespace std;
int n, m;
int k;
bool debug = false;
int f[100005];
int ff(int x) {
  while (x != f[x]) x = f[x];
  return x;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) f[i] = i;
  int a, b;
  long long ans = 1;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    int fa = ff(a), fb = ff(b);
    if (fa == fb) {
      ans = ans * 2 % 1000000009;
    } else {
      f[fa] = fb;
    }
    printf("%I64d\n", ans - 1);
  }
  return 0;
}
