#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define N 400007
usingnamespace std;
int n, m, f[N];
longlong ans;
int find(int x)
{
if (f[x] == 0) return x;
f[x] = find(f[x]);
return f[x];
}
int main()
{
scanf("%d%d", &n, &m);
int q, p;
ans = 1;
for (int i = 1; i <= m; i++)
{
scanf("%d%d", &q, &p);
if (find(q) != find(p))
{
f[find(q)] = find(p);
}
else ans *= 2;
ans %= 1000000009;
printf("%lld\n", ans - 1);
}
}