#include <bits/stdc++.h>
using namespace std;
long long n, m, ans, w[300000], d[300000], a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    w[i] = i;
    d[i] = 1;
  }
  ans = 1;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    while (a != w[a]) a = w[a];
    while (b != w[b]) b = w[b];
    if (a != b) {
      if (d[a] > d[b]) {
        w[b] = a;
      } else {
        w[a] = b;
        if (d[a] == d[b]) d[b]++;
      }
    } else
      ans = ans * 2 % 1000000009;
    cout << (ans + 1000000009 - 1) % 1000000009 << endl;
  }
  cin.get();
  cin.get();
  return 0;
}
