#include <bits/stdc++.h>
using namespace std;
int S[100010];
int Find(int u) { return (u == S[u] ? S[u] : S[u] = Find(S[u])); }
void Union(int u, int v) {
  u = Find(S[u]);
  v = Find(S[v]);
  rand() & 1 ? S[u] = v : S[v] = u;
}
int main() {
  const int MOD = 1000000009;
  int n, m;
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= n; i++) S[i] = i;
  for (int i = 0, res = 0; i < m; i++) {
    int u, v;
    scanf("%d %d\n", &u, &v);
    if (Find(u) == Find(v))
      res = ((res << 1) + 1) % MOD;
    else
      Union(u, v);
    printf("%d\n", res);
  }
exit:
  return (0);
}
