#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

const int SIZE = 51;
int na, ma, nb, mb;
bool A[SIZE][SIZE];
bool B[SIZE][SIZE];

bool input() {
    if ( ! ( cin >> na >> ma ) ) return false;
    for ( int i = 0; i < na; ++ i ) {
        for ( int j = 0; j < ma; ++ j ) {
            char c;
            cin >> c;
            A[i][j] = c == '1';
        }
    }
    cin >> nb >> mb;
    for ( int i = 0; i < nb; ++ i ) {
        for ( int j = 0; j < mb; ++ j ) {
            char c;
            cin >> c;
            B[i][j] = c == '1';
        }
    }
    return true;
}

void solve() {
    int res_r = 0, res_c = 0, max_cnt = 0;

    int n = min( na, nb ), m = min( ma, mb );
    for ( int rb = -nb; rb + n - 1 < nb; ++ rb ) {
        for ( int cb = -mb; cb + m - 1 < mb; ++ cb ) {
            for ( int ra = 0; ra + n - 1 < na; ++ ra ) {
                for ( int ca = 0; ca + m - 1 < ma; ++ ca ) {
                    int cnt = 0;
                    for ( int i = 0; i < n; ++ i ) {
                        for ( int j = 0; j < m; ++ j ) {
                            if ( rb+i >= 0 && rb+i < nb && cb+j >= 0 && cb+j < mb ) {
                                if ( A[ra+i][ca+j] && B[rb+i][cb+j] ) {
                                    cnt ++;
                                }
                            }
                        }
                    }
                    if ( cnt > max_cnt ) {
                        res_r = rb - ra;
                        res_c = cb - ca;
                        max_cnt = cnt;
                    }
                }
            }
        }
    }

    cout << res_r << " " << res_c << endl;
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

const int SIZE = 51;
int na, ma, nb, mb;
bool A[SIZE][SIZE];
bool B[SIZE][SIZE];

bool input() {
    if ( ! ( cin >> na >> ma ) ) return false;
    for ( int i = 0; i < na; ++ i ) {
        for ( int j = 0; j < ma; ++ j ) {
            char c;
            cin >> c;
            A[i][j] = c == '1';
        }
    }
    cin >> nb >> mb;
    for ( int i = 0; i < nb; ++ i ) {
        for ( int j = 0; j < mb; ++ j ) {
            char c;
            cin >> c;
            B[i][j] = c == '1';
        }
    }
    return true;
}

void solve() {
    int res_x = 0, res_y = 0, max_cnt = 0;

    int n = min( na, nb ), m = min( ma, mb );
    for ( int rb = 0; rb + n - 1 < nb; ++ rb ) {
        for ( int cb = 0; cb + m - 1 < mb; ++ cb ) {
            for ( int ra = 0; ra + n - 1 < na; ++ ra ) {
                for ( int ca = 0; ca + m - 1 < ma; ++ ca ) {
                    int cnt = 0;
                    for ( int i = 0; i < n; ++ i ) {
                        for ( int j = 0; j < m; ++ j ) {
                            if ( A[ra+i][ca+j] && B[rb+i][cb+j] ) {
                                cnt ++;
                            }
                        }
                    }
                    if ( cnt > max_cnt ) {
                        res_x = cb - ca;
                        res_y = rb - ra;
                        max_cnt = cnt;
                    }
                }
            }
        }
    }

    cout << res_x << " " << res_y << endl;
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

const int SIZE = 51;
int na, ma, nb, mb;
bool A[SIZE][SIZE];
bool B[SIZE][SIZE];

bool input() {
    if ( ! ( cin >> na >> ma ) ) return false;
    for ( int i = 0; i < na; ++ i ) {
        for ( int j = 0; j < ma; ++ j ) {
            char c;
            cin >> c;
            A[i][j] = c == '1';
        }
    }
    cin >> nb >> mb;
    for ( int i = 0; i < nb; ++ i ) {
        for ( int j = 0; j < mb; ++ j ) {
            char c;
            cin >> c;
            B[i][j] = c == '1';
        }
    }
    return true;
}

void solve() {
    int res_r = 0, res_c = 0, max_cnt = 0;

    int n = min( na, nb ), m = min( ma, mb );
    for ( int rb = 0; rb + n - 1 < nb; ++ rb ) {
        for ( int cb = 0; cb + m - 1 < mb; ++ cb ) {
            for ( int ra = 0; ra + n - 1 < na; ++ ra ) {
                for ( int ca = 0; ca + m - 1 < ma; ++ ca ) {
                    int cnt = 0;
                    for ( int i = 0; i < n; ++ i ) {
                        for ( int j = 0; j < m; ++ j ) {
                            if ( A[ra+i][ca+j] && B[rb+i][cb+j] ) {
                                cnt ++;
                            }
                        }
                    }
                    if ( cnt > max_cnt ) {
                        res_r = rb - ra;
                        res_c = cb - ca;
                        max_cnt = cnt;
                    }
                }
            }
        }
    }

    cout << res_r << " " << res_c << endl;
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

const int SIZE = 51;
int na, ma, nb, mb;
bool A[SIZE][SIZE];
bool B[SIZE][SIZE];

bool input() {
    if ( ! ( cin >> na >> ma ) ) return false;
    for ( int i = 0; i < na; ++ i ) {
        for ( int j = 0; j < ma; ++ j ) {
            char c;
            cin >> c;
            A[i][j] = c == '1';
        }
    }
    cin >> nb >> mb;
    for ( int i = 0; i < nb; ++ i ) {
        for ( int j = 0; j < mb; ++ j ) {
            char c;
            cin >> c;
            B[i][j] = c == '1';
        }
    }
    return true;
}

void solve() {
    int res_r = 0, res_c = 0, max_cnt = 0;

    int n = min( na, nb ), m = min( ma, mb );
    for ( int rb = -n; rb + n - 1 < nb; ++ rb ) {
        for ( int cb = -n; cb + m - 1 < mb; ++ cb ) {
            for ( int ra = 0; ra + n - 1 < na; ++ ra ) {
                for ( int ca = 0; ca + m - 1 < ma; ++ ca ) {
                    int cnt = 0;
                    for ( int i = 0; i < n; ++ i ) {
                        for ( int j = 0; j < m; ++ j ) {
                            if ( rb+i >= 0 && rb+i < nb && cb+j >= 0 && cb+j < mb ) {
                                if ( A[ra+i][ca+j] && B[rb+i][cb+j] ) {
                                    cnt ++;
                                }
                            }
                        }
                    }
                    if ( cnt > max_cnt ) {
                        res_r = rb - ra;
                        res_c = cb - ca;
                        max_cnt = cnt;
                    }
                }
            }
        }
    }

    cout << res_r << " " << res_c << endl;
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

const int SIZE = 51;
int na, ma, nb, mb;
bool A[SIZE][SIZE];
bool B[SIZE][SIZE];

bool input() {
    if ( ! ( cin >> na >> ma ) ) return false;
    for ( int i = 0; i < na; ++ i ) {
        for ( int j = 0; j < ma; ++ j ) {
            char c;
            cin >> c;
            A[i][j] = c == '1';
        }
    }
    cin >> nb >> mb;
    for ( int i = 0; i < nb; ++ i ) {
        for ( int j = 0; j < mb; ++ j ) {
            char c;
            cin >> c;
            B[i][j] = c == '1';
        }
    }
    return true;
}

void solve() {
    int res_r = 0, res_c = 0, max_cnt = 0;

    int n = min( na, nb ), m = min( ma, mb );
    for ( int rb = -nb; rb < nb; ++ rb ) {
        for ( int cb = -mb; cb < mb; ++ cb ) {
            for ( int ra = 0; ra + n - 1 < na; ++ ra ) {
                for ( int ca = 0; ca + m - 1 < ma; ++ ca ) {
                    int cnt = 0;
                    for ( int i = 0; i < n; ++ i ) {
                        for ( int j = 0; j < m; ++ j ) {
                            if ( rb+i >= 0 && rb+i < nb && cb+j >= 0 && cb+j < mb ) {
                                if ( A[ra+i][ca+j] && B[rb+i][cb+j] ) {
                                    cnt ++;
                                }
                            }
                        }
                    }
                    if ( cnt > max_cnt ) {
                        res_r = rb - ra;
                        res_c = cb - ca;
                        max_cnt = cnt;
                    }
                }
            }
        }
    }

    cout << res_r << " " << res_c << endl;
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define DWN(i,h,l) for(int i=(h);i>=(l);--i)
#define CLR(vis) memset(vis,0,sizeof(vis))
#define MST(vis,pos) memset(vis,pos,sizeof(vis))
#define MAX3(a,b,c) max(a,max(b,c))
#define MAX4(a,b,c,d) max(max(a,b),max(c,d))
#define MIN3(a,b,c) min(a,min(b,c))
#define MIN4(a,b,c,d) min(min(a,b),min(c,d))
#define PI acos(-1.0)
#define INF 1000000000
#define LINF 1000000000000000000LL
#define eps 1e-8

typedef long long ll;

int na,ma,nb,mb;

char a[55][55],b[55][55];

int main()
{
    cin>>na>>ma;
    FOR(i,1,na)
      scanf("%s",a[i]+1);
    cin>>nb>>mb;
    FOR(i,1,nb)
      scanf("%s",b[i]+1);
    //cout<<b[1]<<endl;
    int ans=-INF,l=0,r=0;
    int res;
    FOR(i,min(-nb,-na),max(nb,na))
    {
        FOR(j,min(-mb,-ma),max(mb,ma))
        {
            res=0;
            for(int p=1;p<=na;p++)
            {
                if(p+i<1||p+i>nb)
                  continue;
                for(int q=1;q<=ma;q++)
                 {
                     if(q+j<1||q+j>mb)
                        continue;
                    res+=((a[p][q]-'0')*(b[p+i][q+j]-'0'));
                        //cout<<p<<" "<<q<<endl;
                        //cout<<a[p][q]<<" "<<b[p+i][q+j]<<endl;
                        //cout<<(a[p][q]-'0')*(b[p+i][q+j]-'0')<<" "<<(a[p][q]-'0')<<" "<<(b[p+i][q+j]-'0')<<endl;

                }
            }
            if(res>ans)
            {
                ans=res;
               // cout<<res<<" "<<i<<" "<<j<<endl;
                l=i,r=j;
            }
        }
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define DWN(i,h,l) for(int i=(h);i>=(l);--i)
#define CLR(vis) memset(vis,0,sizeof(vis))
#define MST(vis,pos) memset(vis,pos,sizeof(vis))
#define MAX3(a,b,c) max(a,max(b,c))
#define MAX4(a,b,c,d) max(max(a,b),max(c,d))
#define MIN3(a,b,c) min(a,min(b,c))
#define MIN4(a,b,c,d) min(min(a,b),min(c,d))
#define PI acos(-1.0)
#define INF 1000000000
#define LINF 1000000000000000000LL
#define eps 1e-8

typedef long long ll;

int na,ma,nb,mb;

char a[55][55],b[55][55];

int main()
{
    cin>>na>>ma;
    FOR(i,1,na)
      scanf("%s",a[i]);
    cin>>nb>>mb;
    FOR(i,1,nb)
      scanf("%s",b[i]);
    int ans=-INF,l=0,r=0;
    int res=0;
    FOR(i,-nb,nb)
    {
        FOR(j,-mb,mb)
        {
            res=0;
            for(int p=1;p<=na;p++)
                {
                    if(p+i<1||p+i>nb)
                        continue;
                    for(int q=1;q<=ma;q++)
                 {
                     if(q+j<1||q+j>mb)
                        continue;
                     res+=(a[p][q]-'0')*(b[p+i][q+j]-'0');

                 }
                }
            if(res>ans)
                     {
                         ans=res;
                         l=i,r=j;
                     }
        }
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define DWN(i,h,l) for(int i=(h);i>=(l);--i)
#define CLR(vis) memset(vis,0,sizeof(vis))
#define MST(vis,pos) memset(vis,pos,sizeof(vis))
#define MAX3(a,b,c) max(a,max(b,c))
#define MAX4(a,b,c,d) max(max(a,b),max(c,d))
#define MIN3(a,b,c) min(a,min(b,c))
#define MIN4(a,b,c,d) min(min(a,b),min(c,d))
#define PI acos(-1.0)
#define INF 1000000000
#define LINF 1000000000000000000LL
#define eps 1e-8

typedef long long ll;

int na,ma,nb,mb;

char a[55][55],b[55][55];

int main()
{
    cin>>na>>ma;
    FOR(i,1,na)
      scanf("%s",a[i]);
    cin>>nb>>mb;
    FOR(i,1,nb)
      scanf("%s",b[i]);
    int ans=-INF,l=0,r=0;
    int res=0;
    FOR(i,-nb,nb)
    {
        FOR(j,-mb,mb)
        {

            for(int p=1;p<=na;p++)
                {
                    if(p+i<1||p+i>nb)
                        continue;
                    for(int q=1;q<=ma;q++)
                 {
                     if(q+j<1||q+j>mb)
                        continue;
                     res=(a[p][q]-'0')*(b[p+i][q+j]-'0');
                     if(res>ans)
                     {
                         ans=res;
                         l=i,r=j;
                     }
                 }
                }
        }
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define DWN(i,h,l) for(int i=(h);i>=(l);--i)
#define CLR(vis) memset(vis,0,sizeof(vis))
#define MST(vis,pos) memset(vis,pos,sizeof(vis))
#define MAX3(a,b,c) max(a,max(b,c))
#define MAX4(a,b,c,d) max(max(a,b),max(c,d))
#define MIN3(a,b,c) min(a,min(b,c))
#define MIN4(a,b,c,d) min(min(a,b),min(c,d))
#define PI acos(-1.0)
#define INF 1000000000
#define LINF 1000000000000000000LL
#define eps 1e-8

typedef long long ll;

int na,ma,nb,mb;

char a[55][55],b[55][55];

int main()
{
    cin>>na>>ma;
    FOR(i,1,na)
      scanf("%s",a[i]);
    cin>>nb>>mb;
    FOR(i,1,nb)
      scanf("%s",b[i]);
    int ans=-INF,l=0,r=0;
    int res=0;
    FOR(i,-nb,nb)
    {
        FOR(j,-mb,mb)
        {

            for(int p=1;p<=na;p++)
                for(int q=1;q<=ma;q++)
                 {
                     res=(a[p][q]-'0')*(b[p+i][q+j]-'0');
                     if(res>ans)
                     {
                         ans=res;
                         l=i,r=j;
                     }
                 }
        }
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
const int N=52;
char a[N][N],b[N][N];
int n,m,n1,m1;
int abcd(int x,int y)
{
    int sum=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
              {
                  if(i+x<1||i+x>n1||j+y<1||j+y>m1)
                    continue;
                  if(a[i][j]=='1'&&b[i+x][j+y]=='1')
                  sum++;
              }
    return sum;
}
int main()
{
    int x,y,xx,yy;
    while(~scanf("%d%d",&n,&m))
    {
        getchar();
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                cin >>a[i][j];
        scanf("%d%d",&n1,&m1);
        getchar();
        for(int i=1;i<=n1;i++)
           for(int j=1;j<=m1;j++)
               cin >> b[i][j];
        int maxx=-1;
        for(int i=-51;i<=51;i++)
           for(int j=-51;j<=51;j++)
               if(abcd(i,j)>maxx)
               {
                  maxx=abcd(i,j);
                  xx=i;
                  yy=j;
               }
        printf("%d %d\n",xx,yy);
    }
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define DWN(i,h,l) for(int i=(h);i>=(l);--i)
#define CLR(vis) memset(vis,0,sizeof(vis))
#define MST(vis,pos) memset(vis,pos,sizeof(vis))
#define MAX3(a,b,c) max(a,max(b,c))
#define MAX4(a,b,c,d) max(max(a,b),max(c,d))
#define MIN3(a,b,c) min(a,min(b,c))
#define MIN4(a,b,c,d) min(min(a,b),min(c,d))
#define PI acos(-1.0)
#define INF 1000000000
#define LINF 1000000000000000000LL
#define eps 1e-8

typedef long long ll;

int na,ma,nb,mb;

char a[55][55],b[55][55];

int main()
{
    cin>>na>>ma;
    FOR(i,1,na)
      scanf("%s",a[i]+1);
    cin>>nb>>mb;
    FOR(i,1,nb)
      scanf("%s",b[i]+1);
    //cout<<b[1]<<endl;
    int ans=-INF,l=0,r=0;
    int res;
    FOR(i,min(-nb,-na),min(-nb,-na))
    {
        FOR(j,min(-mb,-ma),min(-mb,-ma))
        {
            res=0;
            for(int p=1;p<=na;p++)
            {
                if(p+i<1||p+i>nb)
                  continue;
                for(int q=1;q<=ma;q++)
                 {
                     if(q+j<1||q+j>mb)
                        continue;
                    res+=((a[p][q]-'0')*(b[p+i][q+j]-'0'));
                        //cout<<p<<" "<<q<<endl;
                        //cout<<a[p][q]<<" "<<b[p+i][q+j]<<endl;
                        //cout<<(a[p][q]-'0')*(b[p+i][q+j]-'0')<<" "<<(a[p][q]-'0')<<" "<<(b[p+i][q+j]-'0')<<endl;

                }
            }
            if(res>ans)
            {
                ans=res;
               // cout<<res<<" "<<i<<" "<<j<<endl;
                l=i,r=j;
            }
        }
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
    int na, ma, nb, mb, i, j, Max, tp, tpx, tpy, x, y, tpn,tpm;
    char s[60][60];
    int s1[60][60], s2[60][60];
    while (cin>>na>>ma)
    {

        for (i=0; i<na; i++)
                cin>>s[i];

        for (i=0; i<na; i++)
            for (j=0; j<ma; j++)
                s1[i][j] = (int)(s[i][j]-'0');

        cin>>nb>>mb;
        for (i=0; i<nb; i++)
                cin>>s[i];
        for (i=0; i<nb; i++)
            for (j=0; j<mb; j++)
                s2[i][j] = (int)(s[i][j]-'0');

        Max = 0;
        tp=0, tpx = 0, tpy = 0;
        tpn = max(na, nb);
        tpm = max(ma, mb);
        for (x = -tpn; x<=tpn; x++)
            for (y = -tpm; y<=tpm; y++)
            {
                    tp = 0;
                    for (i=0; i<na ; i++)
                    {
                        if (i+x >= 0  && i+x < nb)
                        {
                            for (j=0; j<ma; j++)
                            {
                                if (j+y >= 0 && j+y < mb)
                                    tp += (s1[i][j]*s2[i+x][j+y]);
                            }
                        }
                    }

                if (tp >= Max )
                {
                    Max = tp;
                    tpx = x;
                    tpy = y;
                }
            }

        cout<<tpx<<" "<<tpy<<endl;
    }
}

/*
3 2
01
10
00
2 3
001
111
*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.a %= mod;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.b %= mod;
    ans.c = a.b*b.b + a.c*b.c;
    ans.c %= mod;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 18;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
        if ( (1<<i) >= n ) { return crr.a; }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*getFib( it[ind].a, it[ind].b, 1 ));
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val);
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*getFib( it[ind].a, it[ind].b, 1 ));
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val)%mod;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
        if ( (1<<i) >= n ) { return crr.a; }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*it[ind].b );
    modd( it[ind].val );

    it [ind*2].a += it[ind].a;
    modd ( it[ind*2].a );
    it [ind*2].b += it[ind].b;
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val);
    modd ( it[ind].val );
    return ;
}
int dd ( int x ) {
    if ( x >= mod ) { x -= mod; }
    return x;
}
int sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return dd( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        modd( it[i].val );
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long   a, b, c;
    mat () {}
    mat ( long long   a_, long long    b_, long long    c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long    val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long   &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
long long    getFib( long long    a, long long    b, long long    n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( long long    i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long    i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.a %= mod;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.b %= mod;
    ans.c = a.b*b.b + a.c*b.c;
    ans.c %= mod;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 18;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return modd ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long   a, b, c;
    mat () {}
    mat ( int  a_, int   b_, int   c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int   val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
int  mod = 1000000009;

void modd ( int  &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int   getFib( int   a, int   b, int   n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int   i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int   i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int   n, m, k = 19;
void handle (int   ind, int   s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int   stL;
void add ( int   s, int   f, int   ss, int   ff, int   ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
int  dd ( int  x ) {
    if ( x >= mod ) {x -= mod; }
    return x;
}
int   sum ( int   s, int f, int ss, int   ff, int   ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return dd( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int   i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int   i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( int   i = 0 ; i < m ; i ++ ) {
        int   t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*getFib( it[ind].a, it[ind].b, 1 )+mod)%mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val)%mod;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.a %= mod;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.b %= mod;
    ans.c = a.b*b.b + a.c*b.c;
    ans.c %= mod;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 18;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.a %= mod;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.b %= mod;
    ans.c = a.b*b.b + a.c*b.c;
    ans.c %= mod;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 19;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long   a, b, c;
    mat () {}
    mat ( long long   a_, long long    b_, long long    c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long    val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long   &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long   a, b, c;
    mat () {}
    mat ( long long   a_, long long    b_, long long    c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long    val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long   &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
long long    getFib( long long    a, long long    b, long long    n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( long long    i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long    i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long    n, m, k = 19;
void handle (long long    ind, long long    s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long    stL;
void add ( long long    s, long long    f, long long    ss, long long    ff, long long    ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}

long long   sum ( long long    s, long long  f, long long  ss, long long    ff, long long    ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long    i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long    i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( long long    i = 0 ; i < m ; i ++ ) {
        long long    t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.a %= mod;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.b %= mod;
    ans.c = a.b*b.b + a.c*b.c;
    ans.c %= mod;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 18;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 )%mod << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];

mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.c = a.b*b.b + a.c*b.c;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 18;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    return ;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long   a, b, c;
    mat () {}
    mat ( int  a_, int   b_, int   c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int   val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
int  mod = 1000000009;

void modd ( int  &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int   getFib( int   a, int   b, int   n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int   i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int   i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int   n, m, k = 19;
void handle (int   ind, int   s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int   stL;
void add ( int   s, int   f, int   ss, int   ff, int   ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
int  dd ( int  x ) {
    if ( x >= mod ) {x -= mod; }
    return x;
}
int   sum ( int   s, int f, int ss, int   ff, int   ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return dd( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int   i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int   i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( int   i = 0 ; i < m ; i ++ ) {
        int   t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
int mod = 1000000009;
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}

mat pows[10000042];
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 10000042 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[0] );
    }
}

int getFib( int a, int b, int n ) {
    if ( n == 0 ) { return a; }
    n --;
    mat crr ( a, b, a+b );
    crr = mult( crr, pows[n] );
    return crr.a;

    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
        if ( (1<<i) >= n ) { return crr.a; }
    }
    return crr.a;
}

int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*it[ind].b );
    modd( it[ind].val );

    it [ind*2].a += it[ind].a;
    modd ( it[ind*2].a );
    it [ind*2].b += it[ind].b;
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val);
    modd ( it[ind].val );
    return ;
}
int dd ( int x ) {
    if ( x >= mod ) { x -= mod; }
    return x;
}
int sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return dd( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) );
}

int main () {

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        modd( it[i].val );
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
        if ( (1<<i) >= n ) { return crr.a; }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*getFib( it[ind].a, it[ind].b, 1 ));
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val)%mod;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long  a, b, c;
    mat () {}
    mat ( long long  a_, long long  b_, long long  c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long  val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = a.a*b.a + a.b*b.b;
    ans.a %= mod;
    ans.b =  a.a*b.b + a.b*b.c;
    ans.b %= mod;
    ans.c = a.b*b.b + a.c*b.c;
    ans.c %= mod;
    return ans;
}
mat pows[32];
long long  getFib( long long  a, long long  b, long long  n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    mat x( 0, 1, 1 );
    for ( long long  i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long  i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long  n, m, k = 19;
void handle (long long  ind, long long  s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 );
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long  stL;
void add ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}
long long dd ( long long x ) {
    if ( x >= mod ) {x -= mod; }
    return x;
}
long long  sum ( long long  s, long long  f, long long  ss, long long  ff, long long  ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return dd( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) );
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( long long  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( long long  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
    }
    for ( long long  i = 0 ; i < m ; i ++ ) {
        long long  t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    long long   a, b, c;
    mat () {}
    mat ( long long   a_, long long    b_, long long    c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    long long    val, a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long   &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
long long    getFib( long long    a, long long    b, long long    n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( long long    i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
    }
    return crr.a%mod;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( long long    i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
long long    n, m, k = 19;
void handle (long long    ind, long long    s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += getFib( it[ind].a, it[ind].b, s+1 ) - getFib( it[ind].a, it[ind].b, 1 )+mod;
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
long long    stL;
void add ( long long    s, long long    f, long long    ss, long long    ff, long long    ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        modd ( it[ind].a );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        modd ( it[ind].b );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = it[ind*2].val + it[ind*2+1].val;
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/


#include <iostream>
using namespace std;
struct mat {
    int a, b, c;
    mat () {}
    mat ( int a_, int b_, int c_ ) { a = a_; b = b_; c = c_; }
};
struct v {
    int val;
    int a, b;
    v () { a = 0, b = 0, val = 0; }
}it[10000042];
long long   mod = 1000000009;

void modd ( long long &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
void modd ( int &a ) {
    if ( a < 0 ) { a += mod; }
    if ( a >= mod ) { a -= mod; }
    if ( a >= mod ) { a %= mod; }
}
mat mult ( mat a, mat b ) {
    mat ans;
    ans.a = (1LL*a.a*b.a + 1LL*a.b*b.b)%mod;
    ans.b =  (1LL*a.a*b.b + 1LL*a.b*b.c)%mod;
    ans.c = (1LL*a.b*b.b + 1LL*a.c*b.c)%mod;
    return ans;
}
mat pows[32];
int getFib( int a, int b, int n ) {
    if ( n == -1 ) { return 0; }
    mat crr ( a, b, a+b );
    for ( int i = 0 ; i < 32 ; i ++ ) {
        if ( n&(1<<i) ) {
            crr = mult( crr, pows[i] );
        }
        if ( (1<<i) >= n ) { return crr.a; }
    }
    return crr.a;
}
void prePows ( ) {
    pows[0] = mat ( 0, 1, 1 );
    for ( int i = 1 ; i < 32 ; i ++ ) {
        pows[i] = mult( pows[i-1], pows[i-1] );
    }
}
int n, m, k = 19;
void handle (int ind, int s ) {
    if ( it[ind].a == 0 && it[ind].b == 0 ) { return; }
    if ( ind >= (1<<k) ) {
        it[ind].val += it[ind].a;
        modd( it[ind].val );
        it[ind].a = 0; it[ind].b = 0;
    }

    it[ind].val += (1LL*getFib( it[ind].a, it[ind].b, s+1 ) - 1LL*getFib( it[ind].a, it[ind].b, 1 ));
    modd( it[ind].val );

    it [ind*2].a += getFib( it[ind].a, it[ind].b, 0 );
    modd ( it[ind*2].a );
    it [ind*2].b += getFib( it[ind].a, it[ind].b, 1 );
    modd ( it[ind*2].b );

    it[ind*2+1].a += getFib( it[ind].a, it[ind].b, s/2 );
    modd ( it[ind*2+1].a );
    it[ind*2+1].b += getFib( it[ind].a, it[ind].b, s/2+1 );
    modd ( it[ind*2+1].b );

    it[ind].a = 0;
    it[ind].b = 0;
}
int stL;
void add ( int s, int f, int ss, int ff, int ind ) {
    //handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return ; }
    if ( ss <= s && f <= ff ) {
        it[ind].a += getFib( 1, 1, s-stL );
        it[ind].b += getFib( 1, 1, s-stL+1 );
        handle( ind, f-s );
        return;
    }
    add( s, (s+f)/2, ss, ff, ind*2 );
    add( (s+f)/2, f, ss, ff, ind*2+1 );
    it[ind].val = (it[ind*2].val + it[ind*2+1].val);
    modd ( it[ind].val );
    return ;
}

long long sum ( int s, int f, int ss, int  ff, int ind ) {
    handle( ind, f-s );
    if ( f <= ss || ff <= s ) { return 0; }
    if ( ss <= s && f <= ff ) { return it[ind].val; }
    return ( sum ( s, (s+f)/2, ss, ff, ind*2 )+sum( (s+f)/2, f, ss, ff, ind*2+1 ) )%mod;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    prePows () ;

    cin >> n >> m;
    for ( int  i = 0 ; i < n ; i ++ ) {
        cin >> it[i+(1<<k)].val;
    }
    for ( int  i = (1<<k)-1 ; i ; i-- ) {
        it[i].val = it[i*2].val + it[i*2+1].val;
        it[i].val %= mod;
    }
    for ( int i = 0 ; i < m ; i ++ ) {
        int t, l ,r;
        cin >> t >> l >> r;
        l --;
        if ( t == 1 ) {
            stL = l;
            add ( 0, (1<<k), l, r, 1 );
        }else {
            cout << sum ( 0, (1<<k), l, r, 1 ) << "\n";
        }
    }
    return 0;
}
/*

a b     a+b   a+2b     2a+3b  3a+5b   5a+8b
a a+b  2a+b   3a+3b    5a+6b  8a+11b 13a+19b

0 1   1     2    3      5     8     13     21     55
0 1   2     4    7     12    20     33     54

3    4     7    11    18     29
3    7     14   25

*/