#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 20;
const int N5 = 300 * 1000 + 10;
const int N3 = 3000 + 20;
const long long mod = 1000 * 1000 * 1000 + 9;
const long long inf = LLONG_MAX / 2;
long long dp[2][N], par[N], rnk[N];
long long __pow(long long x, int y) {
  if (y == 0) return 1;
  return __pow(x * x % mod, y / 2) % mod * (y & 1 ? x : 1) % mod;
}
int find_root(int v) {
  if (par[v] == v) {
    return v;
  }
  return par[v] = find_root(par[v]);
}
void _merge(int a, int b) {
  int r_a = find_root(a);
  int r_b = find_root(b);
  if (rnk[r_a] > rnk[r_b]) {
    swap(r_a, r_b);
  }
  par[r_a] = r_b;
  if (rnk[r_a] == rnk[r_b]) {
    rnk[r_b]++;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int t = 0;
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (find_root(x) != find_root(y)) {
      t++;
      _merge(x, y);
    }
    cout << ((__pow(2, i - t) + mod) - 1) % mod << "\n";
  }
}
