#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
const int N = 1e6 + 10;
const long long INF = 1e18;
const long double EPS = 1e-12;
int p[100005];
int find(int u) {
  if (p[u] == u) {
    return u;
  } else {
    p[u] = find(p[u]);
    return p[u];
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = (int)1; i < (int)n + 1; i++) {
    p[i] = i;
  }
  long long ans = 1LL;
  for (int i = 0; i < (int)m; i++) {
    int x, y;
    cin >> x >> y;
    int px = find(x);
    int py = find(y);
    if (px == py) {
      ans *= 2LL;
      ans %= mod;
    } else {
      p[py] = px;
    }
    cout << (ans - 1LL) << endl;
  }
  return 0;
}
