#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
int n, m, st[100005];
int find_st(int i) {
  if (st[i] == i) return i;
  return st[i] = find_st(st[i]);
}
void union_st(int x, int y) {
  x = find_st(x);
  y = find_st(y);
  st[x] = y;
}
int main() {
  cin >> n >> m;
  int ans = 1;
  for (int i = 1; i <= n; i++) st[i] = i;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (find_st(a) != find_st(b))
      union_st(a, b);
    else
      ans = ans * 2 % mod;
    printf("%d\n", ans - 1);
  }
  return 0;
}
