#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
int p[100005];
int root(int a) { return p[a] == a ? a : (p[a] = root(p[a])); }
void merge(int a, int b) {
  a = root(a), b = root(b);
  if (a != b) p[a] = b;
}
int main() {
  int ans = 1;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (root(a) != root(b))
      merge(a, b);
    else
      ans = ans * 2 % mod;
    printf("%d\n", (ans - 1 + mod) % mod);
  }
}
