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