447_E. DZY Loves Fibonacci Numbers_36736
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation 

F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2).

DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of n integers: a1, a2, ..., an. Moreover, there are m queries, each query has one of the two types:

  1. Format of the query "1 l r". In reply to the query, you need to add Fi - l + 1 to each element ai, where l ≤ i ≤ r. 
  2. Format of the query "2 l r". In reply to the query you should output the value of <image> modulo 1000000009 (109 + 9). 



Help DZY reply to all the queries.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 300000). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — initial array a.

Then, m lines follow. A single line describes a single query in the format given in the statement. It is guaranteed that for each query inequality 1 ≤ l ≤ r ≤ n holds.

Output

For each query of the second type, print the value of the sum on a single line.

Examples

Input

4 4
1 2 3 4
1 1 4
2 1 4
1 2 4
2 1 3


Output

17
12

Note

After the first query, a = [2, 3, 5, 7].

For the second query, sum = 2 + 3 + 5 + 7 = 17.

After the third query, a = [2, 4, 6, 9].

For the fourth query, sum = 2 + 4 + 6 = 12.
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 5;
const int mod = 1e9 + 9;
const int N = 3 * 1e5 + 5;
namespace FIB {
struct Matrix {
  int a[3][3];
  Matrix() { memset(a, 0, sizeof(a)); }
  Matrix operator*(const Matrix& M2) {
    Matrix result;
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++) {
          result.a[i][j] =
              (result.a[i][j] + 1ll * this->a[i][k] * M2.a[k][j]) % mod;
        }
    return result;
  }
  static Matrix eye() {
    Matrix res;
    for (int i = 0; i < 3; i++) res.a[i][i] = 1;
    return res;
  }
  Matrix exp(int pw) {
    if (pw == 0) return eye();
    if (pw == 1) return *this;
    Matrix half = this->exp(pw / 2);
    if (pw % 2) return half * half * (*this);
    return half * half;
  }
};
Matrix initMat() {
  Matrix res;
  int dx[] = {0, 0, 1, 2, 2};
  int dy[] = {0, 1, 0, 0, 2};
  for (int i = 0; i < 5; i++) res.a[dx[i]][dy[i]] = 1;
  return res;
}
Matrix matrices[N];
void initMatrices() {
  matrices[0] = Matrix::eye();
  matrices[1] = initMat();
  for (int i = 2; i < N; i++) matrices[i] = matrices[i - 1] * matrices[1];
}
pair<int, pair<int, int> > fib(int a, int b, int n) {
  Matrix& base = matrices[n - 1];
  pair<int, pair<int, int> > res;
  res.first = (1ll * base.a[0][0] * b + 1ll * base.a[0][1] * a +
               1ll * base.a[0][2] * a) %
              mod;
  res.second.first = (1ll * base.a[1][0] * b + 1ll * base.a[1][1] * a +
                      1ll * base.a[1][2] * a) %
                     mod;
  res.second.second = (1ll * base.a[2][0] * b + 1ll * base.a[2][1] * a +
                       1ll * base.a[2][2] * a) %
                      mod;
  return res;
}
}  // namespace FIB
namespace SegTree {
int n;
int s[4 * N], a[4 * N], lazyA[4 * N], lazyB[4 * N];
inline int aggr(int val1, int val2) { return (val1 + val2) % mod; }
void build(int l, int r, int id) {
  if (l == r) {
    s[id] = a[l];
  } else {
    int mid = (l + r) / 2;
    build(l, mid, id * 2);
    build(mid + 1, r, id * 2 + 1);
    s[id] = aggr(s[id * 2], s[id * 2 + 1]);
  }
}
void upd(int id, int l, int r, int va, int vb) {
  if (l == r) {
    s[id] = aggr(s[id], va);
  } else {
    lazyA[id] = aggr(lazyA[id], va);
    lazyB[id] = aggr(lazyB[id], vb);
    s[id] = aggr(s[id], FIB::fib(va, vb, r - l + 1).second.second);
  }
}
void shift(int id, int l, int r) {
  if (lazyA[id]) {
    int mid = (l + r) / 2;
    int va = lazyA[id];
    int vb = lazyB[id];
    upd(id * 2, l, mid, va, vb);
    pair<int, pair<int, int> > rb = FIB::fib(va, vb, mid + 2 - l);
    upd(id * 2 + 1, mid + 1, r, rb.second.first, rb.first);
    lazyA[id] = 0;
    lazyB[id] = 0;
  }
}
void update(int x, int y, int l, int r, int id, int va, int vb) {
  if (l >= x && r <= y) {
    pair<int, pair<int, int> > rb = FIB::fib(va, vb, l - x + 1);
    upd(id, l, r, rb.second.first, rb.first);
    return;
  }
  if (y < l || x > r) return;
  shift(id, l, r);
  int mid = (l + r) / 2;
  update(x, y, l, mid, id * 2, va, vb);
  update(x, y, mid + 1, r, id * 2 + 1, va, vb);
  s[id] = aggr(s[id * 2], s[id * 2 + 1]);
}
int query(int x, int y, int l, int r, int id) {
  if (l >= x && r <= y) {
    return s[id];
  }
  if (y < l || x > r) return 0;
  shift(id, l, r);
  int mid = (l + r) / 2;
  return aggr(query(x, y, l, mid, id * 2), query(x, y, mid + 1, r, id * 2 + 1));
}
}  // namespace SegTree
int main() {
  ios_base::sync_with_stdio(false);
  FIB::initMatrices();
  int n, m;
  cin >> n >> m;
  SegTree::n = n;
  for (int i = 0; i < n; i++) cin >> SegTree::a[i];
  SegTree::build(0, n - 1, 1);
  for (int i = 0; i < m; i++) {
    int choice, a, b;
    cin >> choice >> a >> b;
    a -= 1;
    b -= 1;
    if (choice == 1) {
      SegTree::update(a, b, 0, n - 1, 1, 1, 1);
    } else {
      int ans = SegTree::query(a, b, 0, n - 1, 1);
      cout << ans << endl;
    }
  }
  return 0;
}

4 4
1 2 3 4
1 1 4
2 1 4
1 2 4
2 1 3
 2 2
1 2
2 1 2
2 1 2
 10 20
56 12 68 23 41 29 97 69 79 76
1 3 5
1 8 9
2 3 10
1 7 10
2 1 10
1 5 10
2 2 4
1 2 4
1 5 6
2 1 2
2 4 5
1 1 5
1 8 9
2 5 8
2 4 7
2 9 10
2 4 9
1 2 10
1 2 9
2 7 8
 2 2
1 2
2 1 1
2 1 2
 4 4
1 2 3 8
1 1 4
2 1 4
1 2 4
2 1 3
 10 20
56 12 68 23 41 29 97 69 79 76
1 3 5
1 8 9
2 3 10
1 7 10
2 1 10
1 5 10
2 2 4
1 2 4
1 5 6
2 1 2
2 4 5
1 1 5
1 8 9
2 5 8
2 5 7
2 9 10
2 4 9
1 2 10
1 2 9
2 7 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 4
1 5 6
2 1 2
2 4 5
1 1 5
1 8 9
2 5 8
2 5 7
2 9 10
2 4 9
1 2 10
1 2 9
2 7 8
 4 4
1 2 1 8
2 1 4
2 1 4
1 2 4
2 1 4
 10 20
56 12 68 6 41 29 118 118 79 76
1 3 5
1 8 9
2 3 10
1 7 10
2 1 10
1 5 10
2 2 4
1 2 4
1 5 6
2 1 2
2 4 5
1 1 5
1 8 9
2 5 8
2 5 7
2 9 10
2 4 9
1 2 7
1 2 9
2 7 8
 4 4
1 2 1 4
1 1 4
2 2 4
1 2 3
2 1 3
 4 4
1 2 1 10
1 1 4
2 2 2
1 2 4
2 1 3
 4 3
1 2 1 8
1 2 4
2 1 4
1 2 3
2 1 3

17
12
 3
3
 488
563
105
69
71
256
210
175
373
217
 1
3
 21
12
 488
563
105
69
71
256
181
175
373
217
 19
14
 2
4
 19
10
 471
546
88
69
54
256
181
175
356
217
 17
10
 13
10
 5
 10
10
8
 488
610
107
69
74
272
190
204
401
228
 16
8
 11
10
 4
 10
12
 18
10
 11
2
 10
21
 12
2
 10
19
 488
563
105
69
71
262
214
179
383
221
 1
2
 20
11
 488
563
105
69
141
256
181
175
373
217
 2
5
 19
6
 492
567
88
69
54
277
202
175
377
238
 3
10
 3
 488
564
107
23
74
272
190
204
401
228
 16
 11
9
 8
8
 11
11
2
 9
11
 19
23
 492
567
88
69
54
277
202
175
377
225
 1
 488
511
106
23
71
254
180
170
369
215
 12
12
16
 541
616
88
69
54
326
202
175
426
274
 13
10
 3
10
 16
