#include <bits/stdc++.h>
using namespace std;
int P[1 << 17];
int Parent(int a) { return a == P[a] ? a : (P[a] = Parent(P[a])); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int i;
  for (i = 0; i < n; i++) P[i] = i;
  int res = 1;
  for (i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    int pa = Parent(a);
    int pb = Parent(b);
    if (pa != pb)
      P[pa] = P[b];
    else
      res = (res + res) % 1000000009;
    cout << (res + 1000000009 - 1) % 1000000009 << endl;
  }
  return 0;
};
