using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;

class Program
{
    int[] p;
    int[] rank;
    void solve()
    {
        int n = nextInt();
        int m = nextInt();
        long res = 1;
        p = new int[n];
        rank = new int[n];
        for (int i = 0; i < n; i++)
            p[i] = i;
        for (int i = 0; i < m; i++)
        {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            if (find(a) != find(b))
            {
                union(find(a), find(b));
            }
            else
                res = 2 * res % 1000000009;
            println((res - 1 + 1000000009) % 1000000009);
        }

    }

    private void union(int x, int y)
    {
        if (rank[x] <= rank[y])
        {
            p[x] = y;
            if (rank[x] == rank[y])
                rank[y]++;
        }
        else
            p[y] = x;
    }

    private int find(int x)
    {
        if (x != p[x])
            p[x] = find(p[x]);
        return p[x];
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        return int.Parse(nextString());
    }
    long nextLong()
    {
        return long.Parse(nextString());
    }
    double nextDouble()
    {
        return double.Parse(nextString());
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;

class Program
{
    int[] p;
    void solve()
    {
        int n = nextInt();
        int m = nextInt();
        long res = 1;
        p = new int[n];
        for (int i = 0; i < n; i++)
            p[i] = i;
        for (int i = 0; i < m; i++)
        {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            if (find(a) != find(b))
            {
                union(find(a), find(b));
            }
            else
                res = 2 * res % 1000000009;
            println((res - 1 + 1000000009) % 1000000009);
        }

    }

    private void union(int x, int y)
    {
        p[x] = y;
    }

    private int find(int x)
    {
        if (x != p[x])
            p[x] = find(p[x]);
        return p[x];
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        return int.Parse(nextString());
    }
    long nextLong()
    {
        return long.Parse(nextString());
    }
    double nextDouble()
    {
        return double.Parse(nextString());
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;

class Program
{
    int[] p;
    int[] rank;
    void solve()
    {
        int n = nextInt();
        int m = nextInt();
        long res = 1;
        p = new int[n];
        rank = new int[n];
        for (int i = 0; i < n; i++)
            p[i] = i;
        for (int i = 0; i < m; i++)
        {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            if (find(a) != find(b))
            {
                union(find(a), find(b));
            }
            else
                res = 2 * res % 1000000009;
            println((res - 1 + 1000000009) % 1000000009);
        }

    }

    private void union(int x, int y)
    {
        if (rank[x] >= rank[y])
        {
            p[x] = y;
            if (rank[x] == rank[y])
                rank[y]++;
        }
        else
            p[y] = x;
    }

    private int find(int x)
    {
        if (x != p[x])
            p[x] = find(p[x]);
        return p[x];
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        return int.Parse(nextString());
    }
    long nextLong()
    {
        return long.Parse(nextString());
    }
    double nextDouble()
    {
        return double.Parse(nextString());
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;

class Fffuuuu {

    class DSU {

        private Int32[] parent, height;

        public DSU(Int32 n) {
            height = new Int32[n];
            parent = new Int32[n];
            for (Int32 i = 0; i < n; ++i) {
                parent[i] = i;
            }
        }

        public Int32 Find(Int32 x) {
            return parent[x] == x ? x : parent[x] = Find(parent[x]);
        }

        public void Unite(Int32 a, Int32 b) {
            if (height[a] == height[b]) {
                parent[a] = b;
                ++height[b];
            } else if (height[a] > height[b]) {
                parent[b] = a;
            } else {
                parent[a] = b;
            }
        }

    }

    void ReadTwo(out Int32 a, out Int32 b) {
        String[] tok = Console.ReadLine().Split(' ');
        a = Int32.Parse(tok[0]);
        b = Int32.Parse(tok[1]);
    }

    public Fffuuuu() {
        Int32 n, m, a, b, res = 1;
        ReadTwo(out n, out m);
        DSU dsu = new DSU(n);
        while (--m >= 0) {
            ReadTwo(out a, out b);
            a = dsu.Find(a - 1);
            b = dsu.Find(b - 1);
            if (a == b) {
                res = (res * 2) % 1000000009;
            } else {
                dsu.Unite(a, b);
            }
            Console.WriteLine(res - 1);
        }
    }

    public static void Main() {
#if DEBUG
        Console.SetIn(new System.IO.StreamReader("in.txt"));
#endif
        new Fffuuuu();
    }
}


n, m = map(int, input().split())

p, r = list(range(n + 1)), [0] * (n + 1)

def find(x):
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]

def union(x, y):
    x, y = find(x), find(y)
    if x == y: return 0
    if r[x] < r[y]: x, y = y, x
    p[y] = x
    r[x] += r[x] == r[y]
    return 1

MOD = 10 ** 9 + 7
ans = 1
out = []
for _ in range(m):
    u, v = map(int, input().split())
    if not union(u, v):
        ans = (ans << 1) % MOD
    out.append((ans + MOD - 1) % MOD)
print(*out, sep='\n')


n, m = map(int, input().split())

p, r = list(range(n + 1)), [0] * (n + 1)

def find(x):
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]

def union(x, y):
    x, y = find(x), find(y)
    if x == y: return 0
    if r[x] < r[y]: x, y = y, x
    p[y] = x
    r[x] += r[x] == r[y]
    return 1

MOD = 10 ** 9 + 9
ans = 1
out = []
for _ in range(m):
    u, v = map(int, input().split())
    if not union(u, v):
        ans = (ans << 1) % MOD
    out.append((ans + MOD - 1) % MOD)
print(*out, sep='\n')


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxN = 100*1000 + 5;
const int mod = 1000*1000*1000 + 9;

int par[maxN], sz[maxN];
int ans[maxN];
int get_par(int v)
{
    if(v == par[v]) return v;
    return par[v] = get_par(par[v]);
}
void merge(int v, int u)
{
    if(sz[v] < sz[u]) swap(v, u);
    sz[v] += sz[u];
    par[u] = v;
}
main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; i ++) ans[i] = sz[i] = 1, par[i] = i;
    int sum = 0;
    for(int i = 0; i < m; i ++)
    {
	  int d, k; cin >> d >> k; d --; k --;
	  d = get_par(d); k = get_par(k);
	  if(d == k)
	  {
		sum += mod - ans[d] + 1; sum %= mod;
		ans[d] <<= 1; ans[d] %= mod;
		sum += ans[d] - 1; sum %= mod;
		cout << sum << endl;
		continue;
	  }
	  merge(d, k);
	  cout << sum << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxN = 100*1000 + 5;
const int mod = 1000*1000*1000 + 9;

int par[maxN], sz[maxN];

int get_par(int v)
{
    if(v == par[v]) return v;
    return par[v] = get_par(par[v]);
}
void merge(int v, int u)
{
    if(sz[v] < sz[u]) swap(v, u);
    sz[v] += sz[u];
    par[u] = v;
}
main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; i ++) sz[i] = 1, par[i] = i;
    int sum = 1;
    for(int i = 0; i < m; i ++)
    {
	  int d, k; cin >> d >> k; d --; k --;
	  d = get_par(d); k = get_par(k);
	  if(d == k)
		sum <<= 1, sum %= mod;
	  else merge(d, k);
	  cout << sum - 1 << endl;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

typedef long long ll ;

const int MAXN = (int)1e5 + 10 ;
const int mod = (int)1e9 + 9 ;

int fa[MAXN] ;
ll tot = 0LL ;
int n , m ;
int getfa(int x){
    if (x==fa[x]) return x;
    return fa[x]=getfa(fa[x]);
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0 ; i < n ; i++) fa[i]=i ;
    for (int i = 0 ; i < m ; i++){
        int a , b ;
        scanf("%d%d",&a,&b) ;
        if (getfa(a)!=getfa(b))
            fa[getfa(a)]=getfa(b);
        else tot=(tot*2+1) % mod ;
        cout<<tot<<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>

#include <string>
#include <sstream>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#define Sz(x) (int((x).size()))
#define All(x) ((x).begin(), (x).end())

template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
#define foreach(i, x) for(__typeof((x).begin()) i = (x).begin(); i != (x).end(); i ++)
template<typename C> ostream& operator<<(ostream& os, const vector<C>& v) { foreach(__it, v) os << *(__it) << ' '; return os; }

typedef double real;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pip;

const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const real eps = 1e-5;

const int maxn = 100500;
const int mod = 1000*1000*1000 + 9;

struct dsu_t {
	int arr[maxn];
	dsu_t() {
		for(int i=0; i<maxn; i++) arr[i] = i;
	}
	inline int get(int p) {
		return arr[p] == p ? p : arr[p] = get(arr[p]);
	}
	inline void un(int a, int b) {
		int aa = get(a);
		int bb = get(b);
		if(rand()&1)
			arr[aa] = bb;
		else
			arr[bb] = aa;
	}
} dsu;

int main() {
	int n, m; cin >> n >> m;
	int res = 1;
	for(int i =0; i<m;i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		int aa = dsu.get(a);
		int bb = dsu.get(b);
		if(aa == bb) {
			res <<= 1;
			res %= mod;
		} else {
			dsu.un(aa, bb);
		}
		int r = res-1;
		if(r < 0) r += mod;
		cout << r << endl;
	}

	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
const int N = 100100;
const int mod = 1000000009;
int f[N];
int find(int x){ return x == f[x] ? x : f[x] = find(f[x]); }
bool Union(int x, int y){
    int fx = find(x), fy = find(y);
    if (fx == fy)return false;
    if (fx > fy)swap(fx, fy);
    f[fx] = fy;
    return true;
}
int n, m;
int main(){
    while (cin >> n >> m){
        for (int i = 1; i <= n; i++)f[i] = i;
        int ans = 1;
        while (m--){
            int u, v; scanf("%d %d", &u, &v);
            if (Union(u, v)==false)
                ans = (ans + ans) % mod;
            printf("%d\n", ans-1);
        }
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
using namespace std;

#define FOR(i, a, n) for (register int i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define ll long long
#define pb push_back
#define X first
#define Y second
#define EPS 1e-10
#define mp make_pair
#define MFOR(i,m,n) for(int i=m;i>n;i--)
#define error(x) cerr<<endl<<x<<endl;
#define st return 0

void error2(const string &s,const int &t){
    cerr<<endl<<"  "<<s<<" = "<<t<<endl;
}

const int MAXINT=2147483647,MAXSINT=32767,N=1000*100+2;
int cl[N],ncl;

int ff(int a){
    if(cl[a]-a){
        int tmp=cl[a];
        cl[a]=ff(tmp);
        return cl[a];
    }
    else
        return a;
}

int main(){
    ios::sync_with_stdio(false);
    int n,m,t,tt,tmp=0;
    ll ans=1;
    char c;
    cin>>n>>m;
    ncl=n;
    FOR(i,1,n+1)
        cl[i]=i;
    FOR(i,0,m){
        cin>>t>>tt;
        tmp=ncl;
        if(ff(cl[t])-ff(cl[tt])){
            ncl--;
            cl[ff(cl[t])]=ff(cl[tt]);
        }
        if(tmp==ncl)
            ans*=2;
        ans%=N;
        cout<<ans-1<<endl;
    }
    #ifndef ONLINE_JUDGE
        cout<<endl;
        system("pause");
    #endif
    st;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
using namespace std;

#define FOR(i, a, n) for (register int i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define ll long long
#define pb push_back
#define X first
#define Y second
#define EPS 1e-10
#define mp make_pair
#define MFOR(i,m,n) for(int i=m;i>n;i--)
#define error(x) cerr<<endl<<x<<endl;
#define st return 0

void error2(const string &s,const int &t){
    cerr<<endl<<"  "<<s<<" = "<<t<<endl;
}

const int MAXINT=2147483647,MAXSINT=32767,N=1000*1000*1000+9;
int cl[N],ncl;

int ff(int a){
	if(cl[a]-a){
		int tmp=cl[a];
		cl[a]=ff(tmp);
		return cl[a];
	}
	else
		return a;
}

int main(){
	ios::sync_with_stdio(false);
	int n,m,t,tt,tmp=0;
	ll ans=1;
	char c;
	cin>>n>>m;
	ncl=n;
	FOR(i,1,n+1)
		cl[i]=i;
	FOR(i,0,m){
		cin>>t>>tt;
		tmp=ncl;
		if(ff(cl[t])-ff(cl[tt])){
			ncl--;
			cl[ff(cl[t])]=ff(cl[tt]);
		}
		if(tmp==ncl)
			ans*=2;
		ans%=N;
		cout<<ans-1<<endl;
	}
    #ifndef ONLINE_JUDGE
        cout<<endl;
        system("pause");
    #endif
    st;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
using namespace std;

#define FOR(i, a, n) for (register int i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define ll long long
#define pb push_back
#define X first
#define Y second
#define EPS 1e-10
#define mp make_pair
#define MFOR(i,m,n) for(int i=m;i>n;i--)
#define error(x) cerr<<endl<<x<<endl;
#define st return 0

void error2(const string &s,const int &t){
    cerr<<endl<<"  "<<s<<" = "<<t<<endl;
}

const int MAXINT=2147483647,MAXSINT=32767,N=1000ll*1000*1000ll+9;
int cl[1000*300],ncl;

int ff(int a){
    if(cl[a]-a){
        int tmp=cl[a];
        cl[a]=ff(tmp);
        return cl[a];
    }
    else
        return a;
}

int main(){
    ios::sync_with_stdio(false);
    int n,m,t,tt,tmp=0;
    ll ans=1;
    char c;
    cin>>n>>m;
    ncl=n;
    FOR(i,1,n+1)
        cl[i]=i;
    FOR(i,0,m){
        cin>>t>>tt;
        tmp=ncl;
        if(ff(cl[t])-ff(cl[tt])){
            ncl--;
            cl[ff(cl[t])]=ff(cl[tt]);
        }
        if(tmp==ncl)
            ans*=2;
        ans%=N;
        cout<<ans-1<<endl;
    }
    #ifndef ONLINE_JUDGE
        cout<<endl;
        system("pause");
    #endif
    st;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>
using namespace std;

#define FOR(i, a, n) for (register int i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define ll long long
#define pb push_back
#define X first
#define Y second
#define EPS 1e-10
#define mp make_pair
#define MFOR(i,m,n) for(int i=m;i>n;i--)
#define error(x) cerr<<endl<<x<<endl;
#define st return 0

void error2(const string &s,const int &t){
    cerr<<endl<<"  "<<s<<" = "<<t<<endl;
}

const int MAXINT=2147483647,MAXSINT=32767,N=1000*100+2;
int cl[N],ncl;

int ff(int a){
    if(cl[a]-a){
        int tmp=cl[a];
        cl[a]=ff(tmp);
        return cl[a];
    }
    else
        return a;
}

int main(){
    ios::sync_with_stdio(false);
    int n,m,t,tt,tmp=0;
    ll ans=1;
    char c;
    cin>>n>>m;
    ncl=n;
    FOR(i,1,n+1)
        cl[i]=i;
    FOR(i,0,m){
        cin>>t>>tt;
        tmp=ncl;
        if(ff(cl[t])-ff(cl[tt])){
            ncl--;
            cl[ff(cl[t])]=ff(cl[tt]);
        }
        if(tmp==ncl)
            ans*=2,ans%=N;
        cout<<ans-1<<endl;
    }
    #ifndef ONLINE_JUDGE
        cout<<endl;
        system("pause");
    #endif
    st;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

const int N = 10010;
const int MOD = 1000000009;

int p[N];

int find_set(int x) { return p[x]==x?x:p[x]=find_set(p[x]); }

int main() {
       int n, m;
       cin >> n >> m;
       long long ans = 1;
       for (int i = 0; i < n; ++i) p[i] = i;
       for (int i = 0; i < m; ++i) {
              int a, b; cin >> a >> b; a--; b--;
              int x = find_set(a);
              int y = find_set(b);
              if ( x != y ) {
                     p[x] = y;
              }
              else {
                     ans += ans;
                     ans %= MOD;
              }
              cout << (ans-1+MOD) % MOD << endl;
       }
       return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

const int N = 100010;
const int MOD = 1000000009;

int p[N];

int find_set(int x) { return p[x]==x?x:p[x]=find_set(p[x]); }

int main() {
       int n, m;
       cin >> n >> m;
       long long ans = 1;
       for (int i = 0; i < n; ++i) p[i] = i;
       for (int i = 0; i < m; ++i) {
              int a, b; cin >> a >> b; a--; b--;
              int x = find_set(a);
              int y = find_set(b);
              if ( x != y ) {
                     p[x] = y;
              }
              else {
                     ans += ans;
                     ans %= MOD;
              }
              cout << (ans-1+MOD) % MOD << endl;
       }
       return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <utility>
#include <set>
#include <algorithm>
using namespace std;

int p[100050],w[100050];

bool combine(int x, int y){
    while(x!=p[x]) x=p[x]=p[p[x]];
    while(y!=p[y]) y=p[y]=p[p[y]];
    if(x==y) return false;
    if(w[x]<w[y]) w[p[x]=y]+=w[x]; else w[p[y]=x]+=w[y];
    return true;
}

int main(){
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;i++) w[p[i]=i]=1;
    int ans=1;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        if(!combine(--x,--y)) ans=(ans+ans)%1000000009;
        printf("%d\n",(ans+1000000008)%1000000009);
    }
}


#include <cstdio>
#include <algorithm>
using namespace std;

int p[100001],w[100001];

bool combine(int x, int y){
    while(p[x]!=x) x=p[x]=p[p[x]];
    while(p[y]!=y) y=p[y]=p[p[y]];
    if(x==y) return false;
    if(w[x]<w[y]) w[p[x]=y]+=w[x]; else w[p[y]=x]+=w[y];
    return true;
}

int main(){
    int n,m,x,y,ans=1;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) w[p[i]=i]=1;
    while(m--){
        scanf("%d%d",&x,&y);
        if(!combine(x,y)) ans=ans*2%1000000009;
        printf("%d\n",(ans+1000000008)%1000000009);
    }
}


//In the name of God
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define X first
#define Y second
// #define X real()
// #define Y imag()
// #define cin fin
// #define cout fout

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef complex<int> point;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
const ll mod = 1e9 + 9;
const ll maxn = 1e5;

ll n, m, ans, par[maxn];

inline ll findpar (int u)
{
  return par[u] == u ? u : par[u] = findpar(par[u]);
}

int main ()
{
  ios_base :: sync_with_stdio(0);
  cin >> n >> m ;
  ans = 1;
  for(int i = 0 ; i < n ; i++)
    par[i] = i;
  for(int u, v, i = 0 ; i < m ; i++)
    {
      cin >> u >> v ;
      u = findpar(u - 1), v = findpar(v - 1);
      if(u == v)
    ans = ans * 2 % mod;
      else
    par[u] = v;
      cout << (ans + mod - 1) % mod << endl ;
    }
}


#include <functional>
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <complex>
#include <numeric>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

#define all(a)		(a).begin(), (a).end()

typedef long long ll;

const int mod = 1000000009;

int p[100500], n, m;

int f(int i) { return p[i] == i ? i : p[i] = f(p[i]); }

int main(){
	#ifdef LocalHost
	freopen("x.in", "r", stdin);
	freopen("x.out", "w", stdout);
	#endif
	cin >> n >> m;
	for (int i = 0; i < 100500; ++i) p[i] = i;
	int r = 1;
	for (; m --> 0; ) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (f(x) == f(y)) {
			if ((r += r) >= mod) r -= mod;
		} else {
			p[f(x)] = f(y);
		}
		printf("%d\n", (r + mod - 1) % mod);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <complex>
#include <sstream>
#include <iomanip>

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
using namespace std;

const double PI = acos(-1.0);
const int BASE = 1000000009;

int n, m, lab[100111], res = 0;

int getRoot(int u) {
    if (lab[u] < 0) return u;
    else return lab[u] = getRoot(lab[u]);
}

void merge(int u, int v) {
    int x = lab[u] + lab[v];
    if (lab[u] < lab[v]) {
        lab[u] = x;
        lab[v] = u;
    }
    else {
        lab[v] = x;
        lab[u] = v;
    }
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    scanf("%d %d", &n, &m);

    FOR(i,1,n) lab[i] = -1;

    res = 0;
    int u, v;
    while (m--) {
        scanf("%d %d", &u, &v);
        u = getRoot(u); v = getRoot(v);
        if (u != v) {
            merge(u,v);
            u = getRoot(u);
        }
        else {
            res = (res + res + 1) % BASE;
        }
        printf("%d\n", res);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define M 1000000009

void unionInit(int d[],int s){int i;rep(i,s)d[i]=i;}
int unionGet(int d[],int n){int t=n,k;while(d[t]!=t)t=d[t];while(d[n]!=n)k=d[n],d[n]=t,n=k;return n;}
int unionConnect(int d[],int a,int b){a=unionGet(d,a);b=unionGet(d,b);if(a==b)return 0;d[a]=b;return 1;}

int main(){
  int i,j,k,l,m,n;
  int ind[110000];
  int res;

  while(scanf("%d%d",&n,&m)==2){
    unionInit(ind,n);
    res = 1;
    while(m--){
      scanf("%d%d",&i,&j); i--; j--;
      if(unionConnect(ind,i,j)==0) res = (res*2)%M;
      printf("%d\n",(res+M-1)%M);
    }
  }

  return 0;
}


#include <stdio.h>

long father[200005]={0};

long find(long x)
{
 if(x==father[x])
  return x;
 father[x]=find(father[x]);
 return father[x];
}

int main()
{
 long n,i,j,x,y,m;
 long ans=1;

 scanf("%ld%ld",&n,&m);
 for(i=1;i<=n;i++)
   father[i]=i;
 for(i=1;i<=m;i++)
   {
    scanf("%ld%ld",&x,&y);
    if(find(x)==find(y))
     ans=ans*2%1000000009;
    else
     father[find(x)]=father[find(y)];
    printf("%ld\n",ans-1);
   }

 return 0;
}


#include<math.h>
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define oo 1000000000
#define mod 1000000009
#define pi 3.14159265359
#define zero(a) (abb(a)<=1e-7)
#define lowbit(a) ((a)&(-(a)))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abb(a) ((a)>0?(a):(-(a)))
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))

int f[100001];

int getf(int now)
{
   if (f[now]==now)
      return now;
   return f[now]=getf(f[now]);
}

int main()
{
   int i,n,m,a,b,t=1;
   scanf("%d%d",&n,&m);
   for (i=1;i<=n;i++)
      f[i]=i;
   for (i=1;i<=m;i++)
   {
      scanf("%d%d",&a,&b);
      if ((a=getf(a))==(b=getf(b)))
         f[a]=b;
      else
         t=t*2%mod;
      printf("%d\n",(t+mod-1)%mod);
   }
   return 0;
}


#include<math.h>
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define oo 1000000000
#define mod 1000000009
#define pi 3.14159265359
#define zero(a) (abb(a)<=1e-7)
#define lowbit(a) ((a)&(-(a)))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abb(a) ((a)>0?(a):(-(a)))
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))

int f[100001];

int getf(int now)
{
   if (f[now]==now)
      return now;
   return f[now]=getf(f[now]);
}

int main()
{
   int i,n,m,a,b,t=1;
   scanf("%d%d",&n,&m);
   for (i=1;i<=n;i++)
      f[i]=i;
   for (i=1;i<=m;i++)
   {
      scanf("%d%d",&a,&b);
      if ((a=getf(a))!=(b=getf(b)))
         f[a]=b;
      else
         t=t*2%mod;
      printf("%d\n",(t+mod-1)%mod);
   }
   return 0;
}


#include<math.h>
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define oo 1000000000
#define mod 1000000009
#define pi 3.14159265359
#define zero(a) (abb(a)<=1e-7)
#define lowbit(a) ((a)&(-(a)))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abb(a) ((a)>0?(a):(-(a)))
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))

int f[100001];

int getf(int now)
{
   if (f[now]==now)
      return now;
   return f[now]=getf(f[now]);
}

int main()
{
   int i,n,m,a,b,t=1;
   scanf("%d%d",&n,&m);
   for (i=1;i<=n;i++)
      f[i]=i;
   for (i=1;i<=m;i++)
   {
      scanf("%d%d",&a,&b);
      if ((a=getf(a))!=(b=getf(b)))
      {
         t=t*2%mod;
         f[a]=b;
      }
      printf("%d\n",(t+mod-1)%mod);
   }
   return 0;
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {

    public static final int MOD = 1000000009;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        DisjointSet disjointSet = new DisjointSet(n);
        int res = 1;
        while (m-- > 0) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            if (!disjointSet.union(a, b)) {
                res <<= 1;
                if (res >= MOD) res -= MOD;
            }
            out.println(res - 1);
        }
    }

}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine().trim();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

class DisjointSet {
    int[] parent;
    int[] rank;

    public DisjointSet(int size) {
        parent = new int[size];
        rank = new int[size];
        for (int i = 0; i < size; ++i) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    public int findSet(int x) {
        if (parent[x] != x) {
            parent[x] = findSet(parent[x]);
        }
        return parent[x];
    }

    public boolean union(int x, int y) {
        x = findSet(x);
        y = findSet(y);
        if (x != y) {
            if (rank[x] < rank[y]) {
                parent[x] = y;
            } else {
                parent[y] = x;
                if (rank[x] == rank[y]) {
                    ++rank[x];
                }
            }
            return true;
        }
        return false;
    }
}


import java.io.*;
import java.util.*;
/*
 * Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid...
 */
public class Main
{
	static int[]par;
	public static void main(String[]args) throws Exception
	{
		int n=ni(),m=ni();
		par=new int[n];
		long ans=1;
		for(int i=0; i<n; i++)
			par[i]=i;
		while(m-->0) {
			int u=ni()-1,v=ni()-1;
			if(fpar(u)==fpar(v))
				ans=(ans*2)%mod;
			else
				par[par[u]]=par[v];
			pr(ans-1);
		}
		System.out.print(output);
	}
	static int fpar(int i)
	{
		return (par[i]==i)?i:(par[i]=fpar(par[i]));
	}
	///////////////////////////////////////////
	///////////////////////////////////////////
	///template from here
	static final int mod=1000_000_009;
	static final double eps=1e-9;
	static final long inf=100000000000000000L;
	static class pair
	{
		int a,b;
		pair(){}
		pair(int c,int d){a=c;b=d;}
		@Override
		public int hashCode()
		{
			return (a+" "+b).hashCode();
		}
		public boolean equals(Object c)
		{
			return (a==(((pair)c).a)&&b==(((pair)c).b));
		}
	}
	public static void sort(int[][]a)
	{
		Arrays.sort(a, new Comparator<int[]>()
				{
			public int compare(int[]a,int[]b)
			{
				if(a[0]>b[0])
					return 1;
				if(a[0]<b[0])
					return -1;
				return 0;
			}
				});
	}
	static interface combiner
	{
		public int combine(int a, int b);
	}
	static void pr(Object a){output.append(a+"\n");}
	static void pr(){output.append("\n");}
	static void p(Object a){output.append(a);}
	static void pra(int[]a){for(int i:a)output.append(i+" ");output.append("\n");}
	static void pra(long[]a){for(long i:a)output.append(i+" ");output.append("\n");}
	static void pra(String[]a){for(String i:a)output.append(i+" ");output.append("\n");}
	static void pra(double[]a){for(double i:a)output.append(i+" ");output.append("\n");}
	static void sop(Object a){System.out.println(a);}
	static void flush(){System.out.print(output);output=new StringBuilder();}
	static int ni(){return Integer.parseInt(in.next());}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] pnia(int n){int a[]=new int[n+1];for(int i=1; i<=n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static Random rn=new Random();
	static void reverse(int[]a){for(int i=0; i<a.length/2; i++){a[i]^=a[a.length-i-1];a[a.length-i-1]^=a[i];a[i]^=a[a.length-i-1];}}
	static int log2n(long a)
	{
		int te=0;
		while(a>0)
		{
			a>>=1;
			++te;
		}
		return te;
	}
	static class vectorl implements Iterable<Long>
	{
		long a[];
		int size;
		vectorl(){a=new long[10];size=0;}
		vectorl(int n){a=new long[n];size=0;}
		public void add(long b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
		@Override
		public Iterator<Long> iterator() {
			Iterator<Long> hola=new Iterator<Long>()
					{
				int cur=0;
						@Override
						public boolean hasNext() {
							return cur<size;
						}
						@Override
						public Long next() {
							return a[cur++];
						}
					};
			return hola;
		}
	}
	static class vector implements Iterable<Integer>
	{
		int a[],size;
		vector(){a=new int[10];size=0;}
		vector(int n){a=new int[n];size=0;}
		public void add(int b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
		@Override
		public Iterator<Integer> iterator() {
			Iterator<Integer> hola=new Iterator<Integer>()
					{
				int cur=0;
						@Override
						public boolean hasNext() {
							return cur<size;
						}
						@Override
						public Integer next() {
							return a[cur++];
						}
					};
			return hola;
		}
	}
	static void exit(){System.out.print(output);System.exit(0);}
	static int min(int... a){int min=a[0];for(int i:a)min=Math.min(min, i);return min;}
	static int max(int... a){int max=a[0];for(int i:a)max=Math.max(max, i);return max;}
	static int gcd(int... a){int gcd=a[0];for(int i:a)gcd=gcd(gcd, i);return gcd;}
	static long min(long... a){long min=a[0];for(long i:a)min=Math.min(min, i);return min;}
	static long max(long... a){long max=a[0];for(long i:a)max=Math.max(max, i);return max;}
	static long gcd(long... a){long gcd=a[0];for(long i:a)gcd=gcd(gcd, i);return gcd;}
	static String pr(String a, long b){String c="";while(b>0){if(b%2==1)c=c.concat(a);a=a.concat(a);b>>=1;}return c;}
	static long powm(long a, long b, long m){long an=1;long c=a;while(b>0){if(b%2==1)an=(an*c)%m;c=(c*c)%m;b>>=1;}return an;}
	static int gcd(int a, int b){if(b==0)return a;return gcd(b, a%b);}
	static long gcd(long a, long b){if(b==0)return a;return gcd(b, a%b);}
	static class Reader{
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}


import java.io.*;
import java.util.*;
/*
 * Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid...
 */
public class Main
{
	static int[]par;
	public static void main(String[]args) throws Exception
	{
		int n=ni(),m=ni();
		par=new int[n];
		long ans=1;
		for(int i=0; i<n; i++)
			par[i]=i;
		while(m-->0) {
			int u=ni()-1,v=ni()-1;
			if(fpar(u)==fpar(v))
				ans=(ans*2)%mod;
			else
				par[par[u]]=par[v];
			pr(ans-1);
		}
		System.out.print(output);
	}
	static int fpar(int i)
	{
		return (par[i]==i)?i:(fpar(par[i]));
	}
	///////////////////////////////////////////
	///////////////////////////////////////////
	///template from here
	static final int mod=1000_000_009;
	static final double eps=1e-9;
	static final long inf=100000000000000000L;
	static class pair
	{
		int a,b;
		pair(){}
		pair(int c,int d){a=c;b=d;}
		@Override
		public int hashCode()
		{
			return (a+" "+b).hashCode();
		}
		public boolean equals(Object c)
		{
			return (a==(((pair)c).a)&&b==(((pair)c).b));
		}
	}
	public static void sort(int[][]a)
	{
		Arrays.sort(a, new Comparator<int[]>()
				{
			public int compare(int[]a,int[]b)
			{
				if(a[0]>b[0])
					return 1;
				if(a[0]<b[0])
					return -1;
				return 0;
			}
				});
	}
	static interface combiner
	{
		public int combine(int a, int b);
	}
	static void pr(Object a){output.append(a+"\n");}
	static void pr(){output.append("\n");}
	static void p(Object a){output.append(a);}
	static void pra(int[]a){for(int i:a)output.append(i+" ");output.append("\n");}
	static void pra(long[]a){for(long i:a)output.append(i+" ");output.append("\n");}
	static void pra(String[]a){for(String i:a)output.append(i+" ");output.append("\n");}
	static void pra(double[]a){for(double i:a)output.append(i+" ");output.append("\n");}
	static void sop(Object a){System.out.println(a);}
	static void flush(){System.out.print(output);output=new StringBuilder();}
	static int ni(){return Integer.parseInt(in.next());}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] pnia(int n){int a[]=new int[n+1];for(int i=1; i<=n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static Random rn=new Random();
	static void reverse(int[]a){for(int i=0; i<a.length/2; i++){a[i]^=a[a.length-i-1];a[a.length-i-1]^=a[i];a[i]^=a[a.length-i-1];}}
	static int log2n(long a)
	{
		int te=0;
		while(a>0)
		{
			a>>=1;
			++te;
		}
		return te;
	}
	static class vectorl implements Iterable<Long>
	{
		long a[];
		int size;
		vectorl(){a=new long[10];size=0;}
		vectorl(int n){a=new long[n];size=0;}
		public void add(long b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
		@Override
		public Iterator<Long> iterator() {
			Iterator<Long> hola=new Iterator<Long>()
					{
				int cur=0;
						@Override
						public boolean hasNext() {
							return cur<size;
						}
						@Override
						public Long next() {
							return a[cur++];
						}
					};
			return hola;
		}
	}
	static class vector implements Iterable<Integer>
	{
		int a[],size;
		vector(){a=new int[10];size=0;}
		vector(int n){a=new int[n];size=0;}
		public void add(int b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
		@Override
		public Iterator<Integer> iterator() {
			Iterator<Integer> hola=new Iterator<Integer>()
					{
				int cur=0;
						@Override
						public boolean hasNext() {
							return cur<size;
						}
						@Override
						public Integer next() {
							return a[cur++];
						}
					};
			return hola;
		}
	}
	static void exit(){System.out.print(output);System.exit(0);}
	static int min(int... a){int min=a[0];for(int i:a)min=Math.min(min, i);return min;}
	static int max(int... a){int max=a[0];for(int i:a)max=Math.max(max, i);return max;}
	static int gcd(int... a){int gcd=a[0];for(int i:a)gcd=gcd(gcd, i);return gcd;}
	static long min(long... a){long min=a[0];for(long i:a)min=Math.min(min, i);return min;}
	static long max(long... a){long max=a[0];for(long i:a)max=Math.max(max, i);return max;}
	static long gcd(long... a){long gcd=a[0];for(long i:a)gcd=gcd(gcd, i);return gcd;}
	static String pr(String a, long b){String c="";while(b>0){if(b%2==1)c=c.concat(a);a=a.concat(a);b>>=1;}return c;}
	static long powm(long a, long b, long m){long an=1;long c=a;while(b>0){if(b%2==1)an=(an*c)%m;c=(c*c)%m;b>>=1;}return an;}
	static int gcd(int a, int b){if(b==0)return a;return gcd(b, a%b);}
	static long gcd(long a, long b){if(b==0)return a;return gcd(b, a%b);}
	static class Reader{
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jack Zhang
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        final static int mod = 1000000009;
        int[] f;

        int find(int x) {
            while (x != f[x]) {
                x = f[x];
            }
            return x;
        }

        Boolean union(int x, int y) {
            int fx = find(x), fy = find(y);
            if (fx == fy) {
                return true;
            }
            if (fx < fy) {
                f[fy] = fx;
            } else {
                f[fx] = fy;
            }
            return false;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            f = IntStream.range(0, n + 1).toArray();
            int ans = 1;
            for (int i = 0; i < m; i++) {
                if (union(in.nextInt(), in.nextInt())) {
                    ans = (2 * ans) % mod;
                }
                out.println(ans - 1);
            }
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jack Zhang
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        final static int mod = 1000000009;
        int[] root;

        int find(int x) {
            while (x != root[x]) {
                x = root[x];
            }
            return x;
        }

        Boolean union(int x, int y) {
            int rootx = find(x), rooty = find(y);
            // choose smaller as root
            if (rootx < rooty) {
                root[rooty] = rootx;
            } else if (rootx > rooty) {
                root[rootx] = rooty;
            }
            return rootx == rooty;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            root = IntStream.range(0, n + 1).toArray();
            int ans = 1;
            for (int i = 0; i < m; i++) {
                if (union(in.nextInt(), in.nextInt())) {
                    ans = (2 * ans) % mod;
                }
                out.println(ans - 1);
            }
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jack Zhang
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        final static int mod = 1000000009;
        int[] f;

        int find(int x) {
            if (x == f[x]) {
                return x;
            } else {
                f[x] = find(f[x]);
                return f[x];
            }
        }

        Boolean union(int x, int y) {
            int fx = find(x), fy = find(y);
            if (fx == fy) {
                return false;
            }
            if (fx > fy) {
                int tmp = fx;
                fx = fy;
                fy = tmp;
            }
            f[fx] = fy;
            return true;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            f = IntStream.range(0, n + 1).toArray();
            int ans = 1;
            for (int i = 0; i < m; i++) {
                if (false == union(in.nextInt(), in.nextInt())) {
                    ans = (2 * ans) % mod;
                }
                out.println(ans - 1);
            }
        }

    }
}


import java.io.*;
import java.util.*;

public class _91C {

	public static void main(String args[]) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solution = new Task();
		solution.solve(in, out);
		out.close();
	}

	static long MOD = 1000000009;

	static class Task {
		int[] dsu;
		int n, m;
		long ans = 1;

		public int find(int v) {
			if (dsu[v] < 0)
				return v;
			return (dsu[v] = find(dsu[v]));
		}

		public void merge(int v, int u) {
			if ((v = find(v)) == (u = find(u))) return ;
			if (dsu[v] > dsu[u]) {
				v = v ^ u;
				u = v ^ u;
				v = v ^ u;
			}
			dsu[v] += dsu[u];
			dsu[u] = v;
		}

		public void solve(InputReader in, PrintWriter out) {
			n = in.nextInt();
			m = in.nextInt();
			dsu = new int[n + 1];
			Arrays.fill(dsu, -1);
			for (int i = 0, v, u; i < m; i++) {
				v = in.nextInt();
				u = in.nextInt();
				if (find(v) == find(u))
					ans = (ans * 2) % MOD;
				merge(v, u);
				out.println((ans - 1 + MOD) % MOD);
			}
		}
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * Created by hama_du on 15/08/03.
 */
public class C {
    static final long MOD = 1000000009;

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();

        UnionFind uf = new UnionFind(n);
        long ans = 1;
        for (int i = 0; i < m ; i++) {
            int a = in.nextInt()-1;
            int b = in.nextInt()-1;
            if (!uf.issame(a, b)) {
                uf.unite(a, b);
            } else {
                ans *= 2;
                ans %= MOD;
            }
            out.println((ans-1+MOD)%MOD);
        }
        out.flush();
    }

    static class UnionFind {
        int[] parent, rank;
        UnionFind(int n) {
            parent = new int[n];
            rank = new int[n];
            for (int i = 0 ; i < n ; i++) {
                parent[i] = i;
                rank[i] = 0;
            }
        }

        int find(int x) {
            if (parent[x] == x) {
                return x;
            }
            parent[x] = find(parent[x]);
            return parent[x];
        }

        void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) {
                return;
            }
            if (rank[x] < rank[y]) {
                parent[x] = y;
            } else {
                parent[y] = x;
                if (rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }
        boolean issame(int x, int y) {
            return (find(x) == find(y));
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}


import java.io.*;
import java.util.*;

public class C implements Runnable{
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	int MOD = (int)1e9+9;

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		/*
		 * Matrix interpretation of this problem makes some sense.
		 * Rank of a matrix is similar to all the linear combinations
		   (i.e the span) of vectors of our edge-node incidence matrix
		   (which is the relationship between edges and nodes).
		 * All linear combinations of the vectors in that matrix that xor
		   to 0 is what makes up a ski base.
		 * As for why the answer is 2^(#edges - rank(incidenceMatrix)) I'm
		   not entirely sure yet. You can find the rank with a gaussian-like
		   method and when doing that you get these zero rows that can be
		   visualized as the vectors that make up the ski base span area.
		 * Still not entirely clear on the linear algebra behind the proof
		   for this problem but finding the pattern of increasing the answer
		   by a factor of 2 isn't too bad.
		 * An alternative way to view this is that when some new edge
		   is connecting two nodes in the same component, every other
		   track that used to exist can be chosen in some combination
		   along with this new cycle that was formed (which can make
		   more tracks).
		 */

		int n = fs.nextInt();
		int m = fs.nextInt();
		int res = 1;

		DSU ds = new DSU(n);
		for(int i = 0; i < m; i++) {
			int u = fs.nextInt() - 1;
			int v = fs.nextInt() - 1;
			if(!ds.union(u, v)) res = mult(res, 2);
			out.println(sub(res, 1));
		}

		out.close();
	}

	int mult(int a, int b) {
		long aa = a % MOD;
		aa *= b;
		aa %= MOD;
		return (int)aa;
	}

	int sub(int a, int b) {
		a -= b;
		while(a < 0) a += MOD;
		return a;

	}

	class DSU {
		int n, p[], rank[];
		DSU(int a) {
			n = a;
			p = new int[n]; rank = new int[n];
			for(int i = 0; i < n; i++) p[i] = i;
		}
		int find(int u) {
			if(u == p[u]) return u;
			return u = find(p[u]);
		}
		boolean union(int u, int v) {
			int pu = find(u), pv = find(v);
			if(pu == pv) return false;
			if(rank[pu] >= rank[pv]) {
				if(rank[pu] == rank[pv]) rank[pu]++;
				p[pv] = pu;
			}
			else {
				p[pu] = pv;
			}
			return true;
		}
	}

	void sort (int[] a) {
		int n = a.length;
		for(int i = 0; i < 50; i++) {
			Random r = new Random();
			int x = r.nextInt(n), y = r.nextInt(n);
			int temp = a[x];
			a[x] = a[y];
			a[y] = temp;
		}
		Arrays.sort(a);
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}


import java.util.*;
import java.util.regex.*;
import java.io.*;
import java.math.BigInteger;
import static java.lang.Math.*;

public class Sol implements Runnable {
	int [] par;

	int parent(int u) {
	 	return (par[u] == u) ? u : (par[u] = parent(par[u]));
	}

	Random rand = new Random();
	boolean unite(int u, int v) {
		int pu = parent(u);
		int pv = parent(v);
		if (pu == pv) {
			return false;
		}
		if (rand.nextBoolean()) {
			par[pu] = pv;
		} else {
			par[pv] = pu;
		}
		return true;
	}

	final int MOD = 1000000009;

	void solve() throws Exception {
		int n = nextInt();
		int m = nextInt();
		par = new int[n];
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}

		int res = 1;
		for (int i = 0; i < m; i++) {
			int u = nextInt() - 1, v = nextInt() - 1;
			if (!unite(u, v)) {
				res = (res * 2) % MOD;
			}
			out.println((res + MOD - 1) % MOD);
		}
	}

	public static void main(String[] args) {
		new Thread(new Sol()).start();
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	StringTokenizer tokenizer = new StringTokenizer("");
	BufferedReader in;
	PrintWriter out;
	long time;

	void sTime() {
		time = System.currentTimeMillis();
	}

	long gTime() {
		return System.currentTimeMillis() - time;
	}

	void gMemory() {
		debug("Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + " kb");
	}

	public void debug(Object o) {
		System.err.println(o);
	}

	boolean seekForToken() {
		while (!tokenizer.hasMoreTokens()) {
			String s = null;
			try {
				s = in.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (s == null)
				return false;
			tokenizer = new StringTokenizer(s);
		}
		return true;
	}

	String nextToken() {
		return seekForToken() ? tokenizer.nextToken() : null;
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	BigInteger nextBig() {
		return new BigInteger(nextToken());
	}
}


import java.util.*;
import java.io.*;

public class ski {
	 int MOD = 1000000009;
	 int n, m;
	 int[] fa = new int[101000];

	 int find(int x)
	 {
		 if(fa[x] < 0) return x;
		 else fa[x] = find(fa[x]);
		 return fa[x];
	 }
	 void solve() throws IOException
	 {
		 Arrays.fill(fa, -1);
		 int ans = 1;
		 n = nextInt();
		 m = nextInt();
		 for(int i = 0; i < m; ++i) {
			 int x, y;
			 x = nextInt();
			 y = nextInt();
			 x = find(x);
			 y = find(y);
			 if(x != y)
				 fa[y] = x;
			 else
				 ans = (ans<<1) % MOD;
			 writer.println((ans-1+MOD)%MOD);
		 }
	 }
	 BufferedReader reader;
	 StringTokenizer tokenizer;
	 PrintWriter writer;

	 public static void main(String[] args) throws IOException
	 {
		 new ski().run();
	 }

	 public void run() throws IOException
	 {
		 reader = new BufferedReader(new InputStreamReader(System.in));
		 tokenizer = null;
		 writer = new PrintWriter(System.out);
		 solve();

		 reader.close();
		 writer.close();
	 }

	 int nextInt() throws IOException {
         return Integer.parseInt(nextToken());
     }

     long nextLong() throws IOException {
         return Long.parseLong(nextToken());
     }

     double nextDouble() throws IOException {
         return Double.parseDouble(nextToken());
     }

     String nextToken() throws IOException {
         while (tokenizer == null || !tokenizer.hasMoreTokens()) {
             tokenizer = new StringTokenizer(reader.readLine());
         }
         return tokenizer.nextToken();
     }
}


import java.io.*;
import java.util.*;

public class C {

    final Random rnd = new Random();

    int[] p;

    int getId(int i) {
        if (p[i] != i) {
            p[i] = getId(p[i]);
        }
        return p[i];
    }

    void union(int i, int j) {
        if ((rnd.nextInt() & 1) == 0) {
            p[j] = i;
        } else {
            p[i] = j;
        }
    }

    void solve() throws IOException {
        in("__std"); out("__std");

        int n = readInt();
        p = new int[n];
        for (int i = 0; i < n; ++i) {
            p[i] = i;
        }
        int m = readInt();
        int ans = 1;
        while (m-- > 0) {
            int a = getId(readInt() - 1);
            int b = getId(readInt() - 1);
            if (a == b) {
                ans = (ans * 2) % 1000000009;
            } else {
                union(a, b);
            }
            println(ans - 1);
        }

        exit();
    }

    void in(String name) throws IOException {
        if (name.equals("__std")) {
            in = new BufferedReader(new InputStreamReader(System.in));
        } else {
            in = new BufferedReader(new FileReader(name));
        }
    }

    void out(String name) throws IOException {
        if (name.equals("__std")) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(name);
        }
    }

    void exit() {
        out.close();
        System.exit(0);
    }

    int readInt() throws IOException {
        return Integer.parseInt(readToken());
    }

    long readLong() throws IOException {
        return Long.parseLong(readToken());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readToken());
    }

    String readLine() throws IOException {
        st = null;
        return in.readLine();
    }

    String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    boolean eof() throws IOException {
        return !in.ready();
    }

    void print(String format, Object ... args) {
        out.println(new Formatter().format(format, args));
    }

    void println(String format, Object ... args) {
        out.println(new Formatter().format(format, args));
    }

    void print(Object value) {
        out.print(value);
    }

    void println(Object value) {
        out.println(value);
    }

    void println() {
        out.println();
    }

    StringTokenizer st;

    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new C().solve();
    }
}


import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    StreamTokenizer in;
    PrintWriter out;

   void run() throws IOException {
       in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
       out=new PrintWriter(new OutputStreamWriter(System.out));
       solve();
       out.flush();

    }

   int nextInt() throws IOException {
       in.nextToken();
       return (int)in.nval;
   }

   void solve() throws IOException {
        int n=nextInt();
        int m=nextInt();
        int mod=1000000009;
        DSJ dsj=new DSJ(n);
        long ans=1;
        for(int i=0;i<m;i++) {
            int a=nextInt();
            int b=nextInt();
            a--;b--;
            if(dsj.find_set(a)==dsj.find_set(b)) {
                ans*=2;
            }
            else {
                dsj.unite(a, b);
            }
            if(ans>mod)
                ans-=mod;
            out.println(ans-1);
        }
    }

   class DSJ {
       int[] p,rank;
       public DSJ(int size) {
           p=new int[size];
           for(int i=0;i<size;i++)
               p[i]=i;
           rank=new int[size];

       }

       public void make_set(int x) {
           p[x]=x;
           rank[x]=0;
       }

       public int find_set(int x) {
           if(x==p[x]) return x;
           return p[x]=find_set(p[x]);
       }

       public void unite(int x, int y) {
           x=find_set(x);
           y=find_set(y);
           if(rank[x]>rank[y])
               p[y]=x;
           else {
               p[x]=y;
               if(rank[x]==rank[y])
                   rank[y]++;
           }
       }
   }

}


import java.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }

    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }

    int[] arr;

    int get(int a) {
    	if (a == arr[a]) {
    		return a;
    	} else {
    		return arr[a] = get(arr[a]);
    	}
    }

	Random r;

    void union(int a, int b) {
    	a = get(a);
    	b = get(b);
		if (r.nextBoolean()) arr[a] = b;
		else arr[b] = a;
    }

    public void run() {
    	r = new Random();
    	int n = nextInt();
    	int m = nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
        	arr[i] = i;
        }
        int cnt = 0;
        for (int i = 0; i < m; i++) {
        	int a = nextInt()-1;
        	int b = nextInt()-1;
        	int sa = get(a);
        	int sb = get(b);
        	if (sa == sb) {
        		cnt = (cnt*2+1)%1000000009;
        	} else {
        		union(a, b);
        	}
        	out.println(cnt);
        }
    	out.flush();
    }
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	long mod = 1000000009L;
	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int n = nextInt();
		int m = nextInt();
		DSU dsu = new DSU(n);
		long ans = 0;
		for(int i = 0; i < m; i++){
			if(dsu.merge(nextInt()-1, nextInt()-1))
				ans = ((ans << 1) + 1)%mod;
			out.println(ans);
		}
		in.close();
		out.close();
	}
	class DSU{
		int p[];
		DSU(int size){
			p = new int[size];
			for(int i = 0; i < size; i++)
				p[i] = i;
		}
		int parent(int a){
			return a == p[a] ? a : (a = parent(p[a]));
		}
		boolean merge(int a,int b){
			int pa = parent(a);
			int pb = parent(b);
			if(pa == pb) return true;
			if(random() > 0.5)
				p[pa] = pb;
			else
				p[pb] = pa;
			return false;
		}

	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "1", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	long mod = 1000000009L;
	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int n = nextInt();
		int m = nextInt();
		DSU dsu = new DSU(n);
		long ans = 0;
		for(int i = 0; i < m; i++){
			if(dsu.merge(nextInt()-1, nextInt()-1))
				ans = ((ans << 1) + 1)%mod;
			out.println(ans);
		}
		in.close();
		out.close();
	}
	class DSU{
		int p[];
		DSU(int size){
			p = new int[size];
			for(int i = 0; i < size; i++)
				p[i] = i;
		}
		int parent(int a){
			return a == p[a] ? a : (p[a] = parent(p[a]));
		}
		boolean merge(int a,int b){
			int pa = parent(a);
			int pb = parent(b);
			if(pa == pb) return true;
			if(random() > 0.5)
				p[pa] = pb;
			else
				p[pb] = pa;
			return false;
		}

	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.*;

/**
 * Generated by Contest helper plug-in
 * Actual solution is at the bottom
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new StreamInputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		run(in, out);
	}

	public static void run(InputReader in, PrintWriter out) {
		Solver solver = new TaskC();
		solver.solve(1, in, out);
		Exit.exit(in, out);
	}
}

abstract class InputReader {
	private boolean finished = false;

	public abstract int read();

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuffer res = new StringBuffer();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public void setFinished(boolean finished) {
		this.finished = finished;
	}

	public abstract void close();
}

class StreamInputReader extends InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar, numChars;

	public StreamInputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public void close() {
		try {
			stream.close();
		} catch (IOException ignored) {
		}
	}
}

class Exit {
	private Exit() {
	}

	public static void exit(InputReader in, PrintWriter out) {
		in.setFinished(true);
		in.close();
		out.close();
	}
}

interface Solver {
	public void solve(int testNumber, InputReader in, PrintWriter out);
}

class RecursiveIndependentSetSystem implements IndependentSetSystem {
	private final int[] color;
	private int setCount;
	private Listener listener;

	public RecursiveIndependentSetSystem(int size) {
		color = new int[size];
		for (int i = 0; i < size; i++)
			color[i] = i;
		setCount = size;
	}

	public RecursiveIndependentSetSystem(RecursiveIndependentSetSystem other) {
		color = other.color.clone();
		setCount = other.setCount;
	}

	public boolean join(int first, int second) {
		first = get(first);
		second = get(second);
		if (first == second)
			return false;
		setCount--;
		color[second] = first;
		if (listener != null)
			listener.joined(second, first);
		return true;
	}

	public int get(int index) {
		if (color[index] == index)
			return index;
		return color[index] = get(color[index]);
	}

	}

interface IndependentSetSystem {
	public boolean join(int first, int second);

	public static interface Listener {
		public void joined(int joinedRoot, int root);
	}
}

class TaskC implements Solver {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int intersectionCount = in.readInt();
		int roadCount = in.readInt();
		int answer = 0;
		IndependentSetSystem setSystem = new RecursiveIndependentSetSystem(intersectionCount);
		for (int i = 0; i < roadCount; i++) {
			int from = in.readInt() - 1;
			int to = in.readInt() - 1;
			if (!setSystem.join(from, to)) {
				answer *= 2;
				answer++;
				if (answer >= 1000000009)
					answer -= 1000000009;
			}
			out.println(answer);
		}
	}
}


import java.io.*;

import java.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main implements Runnable {

	final String filename = "";

	final int mod = 1000000009;

	int[] a, rk;

	int parent(int x) {
		int y = x;
		while (y != a[y])
			y = a[y];
		while (x != y) {
			int z = a[x];
			a[x] = y;
			x = z;
		}
		return y;
	}

	boolean join(int x, int y) {
		x = parent(x);
		y = parent(y);
		if (x == y)
			return false;
		if (rk[x] < rk[y])
			a[x] = y;
		else if (rk[y] > rk[x])
			a[y] = x;
		else {
			a[y] = x;
			rk[x]++;
		}
		return true;
	}

	public void solve() throws Exception {
		int n = iread(), m = iread();
		a = new int[n];
		rk = new int[n];
		long ans = 1;
		for (int i = 0; i < n; i++) {
			a[i] = i;
		}
		for (int i = 0; i < m; i++) {
			int[] t = new int[] { iread() - 1, iread() - 1 };
			if (join(t[0], t[1])) {
			} else {
				ans = (ans * 2) % mod;
			}
			out.write((ans - 1) + "\n");
		}
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			// in = new BufferedReader(new FileReader(filename+".in"));
			// out = new BufferedWriter(new FileWriter(filename+".out"));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int iread() throws Exception {
		return Integer.parseInt(readword());
	}

	public double dread() throws Exception {
		return Double.parseDouble(readword());
	}

	public long lread() throws Exception {
		return Long.parseLong(readword());
	}

	BufferedReader in;

	BufferedWriter out;

	public String readword() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {

		}
		// new Thread(new Main()).start();
		new Thread(null, new Main(), "1", 1 << 25).start();
	}
}


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Scanner;

public class C implements Runnable {

    int[] u;
    int[] h;
    private static final int M = 1000000009;

    public void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        u = new int[n];
        h = new int[n];
        for ( int i = 0; i < n; i ++ ) {
            u[i] = i;
        }
        int r = 1;
        for ( int i = 0; i < m; i ++ ) {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            if ( up( a ) == up( b ) ) {
                r *= 2;
                if ( r > M ) {
                    r -= M;
                }
            }
            join( a, b );
            out.println( r - 1 );
        }
	}

    private void join( int a, int b ) {
        if ( h[up( a )] > h[up( b )] ) {
            u[u[b]] = u[a];
        } else if ( h[u[a]] < h[u[b]] ) {
            u[u[a]] = u[b];
        } else {
            u[u[a]] = u[b];
            h[u[a]] ++;
        }
    }

    private int up( int v ) {
        int t = u[v];
        while ( t != u[t] ) {
            t = u[t];
        }
        u[v] = t;
        return t;
    }

    public StreamTokenizer in;

    public PrintWriter out;

    C() throws IOException {
        in = new StreamTokenizer( new InputStreamReader( System.in ) );
        out = new PrintWriter( System.out );
    }

    int nextInt() throws IOException {
        in.nextToken();
        return ( int ) in.nval;
    }

    void check( boolean f, String msg ) {
        if ( ! f ) {
            out.close();
            throw new RuntimeException( msg );
        }
    }

    void close() throws IOException {
		out.close();
	}

	public void run() {
		try {
			solve();
			close();
		} catch ( Exception e ) {
            e.printStackTrace( out );
            out.flush();
            throw new RuntimeException( e );
		}
	}

	public static void main( String[] args ) throws IOException {
		new Thread( new C() ).start();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class C87 {

    static StreamTokenizer in;
    static PrintWriter out;

    static int nextInt() throws IOException {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws IOException {
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);

        int n = nextInt(), m = nextInt();

        r = new int[n];
        rank = new int[n];
        for (int i = 0; i < n; i++) {
            r[i] = i;
        }

        int cnt = 0;

        for (int i = 0; i < m; i++) {
            int a = get(nextInt()-1), b = get(nextInt()-1);

            if (a == b) {
                cnt++;
            }
            else {
                union(a, b);
            }

            out.println((powmod(2, cnt, MD) - 1 + MD)%MD);
        }

        out.flush();
    }

    static int MD = 1000000009;

    static int powmod(int a, int b, int p) {
        long res = 1, m = a;
        while (b > 0) {
            if ((b&1) != 0) {
                res *= m;
                res %= p;
            }
            m *= m;
            m %= p;
            b >>= 1;
        }
        return (int)res;
    }

    static int[] r, rank;

    static int get(int x) {
        if (r[x] == x) return x;
        else return r[x] = get(r[x]);
    }

    static void union(int a, int b) {
        a = get(a);
        b = get(b);
        if (rank[a] > rank[b]) r[b] = a;
        else {
            r[a] = b;
            if (rank[a] == rank[b]) rank[b]++;
        }
    }
}


import java.io.*;
import java.util.*;
import java.math.*;

public class C implements Runnable {

	static class DSU {
		int[] p;
		int[] r;
		int n;

		public DSU(int n) {
			this.n = n;
			p = new int[n];
			r = new int[n];
			for (int i = 0; i < p.length; i++) {
				p[i] = i;
			}
		}

		int get(int x) {
			return x == p[x] ? x : (p[x] = get(p[x]));
		}

		void union(int x, int y) {
			x = get(x);
			y = get(y);
			if (x == y) {
				return;
			}
			if (r[x] >= r[y]) {
				if (r[x] == r[y]) {
					r[x]++;
				}
				p[y] = x;
			} else {
				p[x] = y;
			}
		}

		void clear() {
			for (int i = 0; i < n; i++) {
				p[i] = i;
				r[i] = 0;
			}
		}
	}

	static final int MOD = 1000000009;

	void solve() {
		int n = nextInt();
		int m = nextInt();
		DSU dsu = new DSU(n);
		int ans = 1;
		for (int i = 0; i < m; i++) {
			int x = nextInt() - 1;
			int y = nextInt() - 1;
			if (dsu.get(x) != dsu.get(y)) {
				dsu.union(x, y);
			} else {
				ans = ans * 2 % MOD;
			}
			out.println((ans + MOD - 1) % MOD);
		}
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	BigInteger nextBigInteger() {
		return sc.nextBigInteger();
	}

	class FastScanner extends BufferedReader {
		StringTokenizer st;
		boolean eof;
		String buf;
		String curLine;
		boolean createST;

		public FastScanner(String fileName) throws FileNotFoundException {
			this(fileName, true);
		}

		public FastScanner(String fileName, boolean createST)
				throws FileNotFoundException {
			super(new FileReader(fileName));
			this.createST = createST;
			nextToken();
		}

		public FastScanner(InputStream stream) {
			this(stream, true);
		}

		public FastScanner(InputStream stream, boolean createST) {
			super(new InputStreamReader(stream));
			this.createST = createST;
			nextToken();
		}

		String nextLine() {
			String ret = curLine;
			if (createST) {
				st = null;
			}
			nextToken();
			return ret;
		}

		String nextToken() {
			if (!createST) {
				try {
					curLine = readLine();
				} catch (Exception e) {
					eof = true;
				}
				return null;
			}
			while (st == null || !st.hasMoreTokens()) {
				try {
					curLine = readLine();
					st = new StringTokenizer(curLine);
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		BigInteger nextBigInteger() {
			return new BigInteger(nextToken());
		}

		public void close() {
			try {
				buf = null;
				st = null;
				curLine = null;
				super.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	public static void main(String[] args) {
		new C().run();
	}
}


import java.io.*;
import java.util.*;

public class SkiBases {

    class Edge {
        int x, y;

        public Edge(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    int[] p;
    int[] cnt;
    int[] r;

    int get(int x) {
        if (p[x] == x)
            return x;
        int t = get(p[x]);
        p[x] = t;
        return p[x];
    }

    void union(int t1, int t2) {
        if (r[t1] == r[t2]) {
            r[t1]++;
        }
        if (r[t1] > r[t2]) {
            p[t2] = t1;
            cnt[t1] += cnt[t2];
        } else {
            p[t1] = t2;
            cnt[t2] += cnt[t1];
        }
    }

    final int modulo = 1000000009;

    int rev(long x) {
        int n = modulo - 2;
        long res = 1;
        while (n > 0) {
            if (n % 2 == 1)
                res = (res * x) % modulo;
            res = (res * res) % modulo;
            n /= 2;
        }
        return (int) (res % modulo);
    }

    long f(long a) {
        return ((a % modulo) * ((a + modulo - 1) % modulo) * rev(2)) % modulo;
    }

    void solve() throws Exception {
        int n = nextInt();
        int m = nextInt();
        p = new int[n];
        cnt = new int[n];
        r = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
        long ans = 1;
        for (int i = 0; i < m; i++) {
            int x = nextInt() - 1;
            int y = nextInt() - 1;
            int t1 = get(x);
            int t2 = get(y);
            if (t1 == t2) {
                cnt[t1]++;
                ans = (ans * 2) % modulo;
            } else
                union(t1, t2);
            out.println((ans + modulo - 1) % modulo);
        }
    }

    void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            // in = new BufferedReader(new FileReader(filename + ".in"));
            // out = new PrintWriter(filename + ".out");

            solve();

            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;
    final String filename = new String("SkiBases").toLowerCase();

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

    public static void main(String[] args) {
        new SkiBases().run();
    }

}


import java.util.*;
import java.math.*;
public class lucksum {

                static int getp(int x,int[] p)
                {
                        if(p[x]==x)
                                return x;
                        else{
                                int res=getp(p[x],p);
                                p[x]=res;
                                return res;
                        }

                }
         public static void main(String[] args)
        {
               Scanner sc=new Scanner(System.in);
               int n=sc.nextInt();
               int m=sc.nextInt();
               int p[]=new int[n+1];
               for(int i=0;i<=n;i++)
                   p[i]=i;
               long res[]=new long[m];
               for(int i=0;i<m;i++)
               {
                   int x=sc.nextInt();
                   int y=sc.nextInt();
                   int px=getp(x,p);
                   int py=getp(y,p);
          //       System.out.println(px);
          //       System.out.println(py);
                   if(px==py)
                   {
                           if(i==0)
                                   res[i]=1;
                           else
                           {
                                   res[i]=2*res[i-1]+1;
                                   res[i]%=1000000009;
                           }
                   }
                   else
                   {
                	   if(i==0)
                		   res[i]=0;
                	   else
                		   res[i]=res[i-1];
                   }
                   p[py]=px;
               }
               for(int i=0;i<m;i++)
                   System.out.println(res[i]);
               return;
        }

}

class MultiList {
    int[] head;
    int[] next;
    int[] vert;
    int[] tramp;
    long[] cost;
    int cnt = 1;

    MultiList(int vNum, int eNum) {
            head = new int [vNum];
            next = new int [eNum + 1];
            vert = new int [eNum + 1];
            tramp = new int [eNum + 1];
            cost = new long [eNum + 1];
    }

    void add(int u, int v, long w,int t) {
            next[cnt] = head[u];
            vert[cnt] = v;
            tramp[cnt] = t;
            cost[cnt] = w;
            head[u] = cnt++;
    }
}

class node implements Comparable<node>{
        public int a;
        public int b;
        public node(int a,int b)
        {
                this.a=a;
                this.b=b;
        }
        public int compareTo(node a)
        {
               if(this.a>a.a)
                   return 1;
               if(this.a<a.a)
                   return -1;
               return a.b-this.b;
        }
}


import java.util.*;
import java.math.*;
public class lucksum {

		static int getp(int x,int[] p)
		{
			if(p[x]==x)
				return x;
			else{
				int res=getp(p[x],p);
				p[x]=res;
				return res;
			}

		}
         public static void main(String[] args)
        {
               Scanner sc=new Scanner(System.in);
               int n=sc.nextInt();
               int m=sc.nextInt();
               int p[]=new int[n+1];
               for(int i=0;i<=n;i++)
            	   p[i]=i;
               long res[]=new long[m];
               for(int i=0;i<m;i++)
               {
            	   int x=sc.nextInt();
            	   int y=sc.nextInt();
            	   int px=getp(x,p);
            	   int py=getp(y,p);
          //  	   System.out.println(px);
          //  	   System.out.println(py);
            	   if(px==py)
            	   {
            		   if(i==0)
            			   res[i]=1;
            		   else
            			   res[i]=2*res[i-1]+1;
            	   }
            	   p[py]=px;
               }
               for(int i=0;i<m;i++)
            	   System.out.println(res[i]);
               return;
        }

}

class MultiList {
    int[] head;
    int[] next;
    int[] vert;
    int[] tramp;
    long[] cost;
    int cnt = 1;

    MultiList(int vNum, int eNum) {
            head = new int [vNum];
            next = new int [eNum + 1];
            vert = new int [eNum + 1];
            tramp = new int [eNum + 1];
            cost = new long [eNum + 1];
    }

    void add(int u, int v, long w,int t) {
            next[cnt] = head[u];
            vert[cnt] = v;
            tramp[cnt] = t;
            cost[cnt] = w;
            head[u] = cnt++;
    }
}

class node implements Comparable<node>{
        public int a;
        public int b;
        public node(int a,int b)
        {
                this.a=a;
                this.b=b;
        }
        public int compareTo(node a)
        {
               if(this.a>a.a)
            	   return 1;
               if(this.a<a.a)
            	   return -1;
               return a.b-this.b;
        }
}