#include <bits/stdc++.h>
inline void swap(int &a, int &b) {
  int tmp = a;
  a = b;
  b = tmp;
}
inline void swap(long long &a, long long &b) {
  long long tmp = a;
  a = b;
  b = tmp;
}
inline void swap(long double &a, long double &b) {
  long double tmp = a;
  a = b;
  b = tmp;
}
inline long double ABS(const long double &val) { return val < 0 ? -val : val; }
inline long long MAX(const long long &a, const long long &b) {
  return a > b ? a : b;
}
inline int MAX(const int &a, const int &b) { return a > b ? a : b; }
inline long long MIN(const long long &a, const long long &b) {
  return a < b ? a : b;
}
inline int MIN(const int &a, const int &b) { return a < b ? a : b; }
inline long double MAX(const long double &a, const long double &b) {
  return a > b ? a : b;
}
inline long double MIN(const long double &a, const long double &b) {
  return a < b ? a : b;
}
const int INTinf = 2147483647;
const int nINTinf = 0 - 2147483648;
using namespace std;
int n, m;
bool met[100005];
int type[100005];
int rtype[100005];
int q, w;
int s1, s2;
long long cnt;
long long con;
int gr;
bool ok;
void rec2(int &q) {
  if (rtype[q] != q) {
    rec2(rtype[q]);
    rtype[q] = s2;
  } else {
    s2 = q;
    if (s1 == s2) {
      ok = true;
      cnt *= 2;
      cnt %= con;
    } else
      ok = false;
  }
}
void rec(int &q) {
  if (rtype[q] != q) {
    rec(rtype[q]);
    rtype[q] = s1;
  } else {
    s1 = q;
    rec2(type[w]);
  }
}
int main() {
  con = 1e9 + 9;
  cnt = 1L;
  gr = 1;
  cin >> n >> m;
  for (int i = 0; i != n; i++) met[i] = false;
  for (int i = 0; i != m; i++) {
    cin >> q >> w;
    if (met[q] == met[w]) {
      if (met[q]) {
        rec(type[q]);
        if (!ok) rtype[rtype[type[q]]] = rtype[type[w]];
      } else {
        met[q] = met[w] = true;
        type[q] = type[w] = rtype[gr] = gr++;
      }
    } else {
      if (met[q]) {
        met[w] = true;
        type[w] = type[q];
      } else {
        met[q] = true;
        type[q] = type[w];
      }
    }
    cout << cnt - 1L << endl;
  }
  return 0;
}
