#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
long long ans = 1;
int n, m;
int u, v;
int fa[100010] = {};
int ff(int x) {
  if (x == fa[x]) return x;
  fa[x] = ff(fa[x]);
  return fa[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    u = ff(u);
    v = ff(v);
    if (u == v) {
      ans *= 2;
      ans %= mod;
    } else
      fa[u] = v;
    printf("%I64d\n", ans - 1);
  }
  return 0;
}
