#include <bits/stdc++.h>
using namespace std;
const long long mo = 1e9 + 9;
const int maxi = 1e6 + 10;
int a[maxi];
string s, t;
vector<int> v[maxi];
int n, m;
int gr[maxi];
void mrdz(int x, int y) {
  x = gr[x];
  y = gr[y];
  if (v[x].size() < v[y].size()) swap(x, y);
  for (int i : v[y]) {
    v[x].push_back(i);
    gr[i] = x;
  }
}
int main() {
  cin >> n >> m;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    v[i].push_back(i);
    gr[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (gr[x] == gr[y])
      ans = (ans * 2 + 1) % mo;
    else
      mrdz(x, y);
    printf("%lld\n", ans);
  }
  return 0;
}
