#include <bits/stdc++.h>
using namespace std;
long long n, m, p[100005], x, y, ans = 1;
int par(int x) {
  if (x == p[x]) return x;
  return p[x] = par(p[x]);
}
void uni(int x, int y) { p[par(y)] = par(x); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) p[i] = i;
  while (m--) {
    cin >> x >> y;
    if (par(x) != par(y))
      uni(x, y);
    else
      ans = (ans * 2) % 1000000009;
    cout << (ans - 1 + 1000000009) % 1000000009 << endl;
  }
  return 0;
}
