#include <bits/stdc++.h>
using namespace std;
typedef long long int arr[262144 << 1];
arr aa, bb;
long long int *f = aa + 1;
long long int *ff = bb + 1;
long long int *g;
struct Node {
  Node *le, *ri;
  long long int del, sum, base;
  Node() : le(0), ri(0), del(0), sum(0), base(0) {}
} * A, *B;
Node *buildtree(int l, int r) {
  Node *ret = new Node();
  if (l == r) {
    ret->base = g[l];
    ret->sum = g[l] * ff[l] % 1000000000;
  } else {
    int m = l + r >> 1;
    ret->le = buildtree(l, m);
    ret->ri = buildtree(m + 1, r);
    ret->base = (ret->le->base + ret->ri->base) % 1000000000;
    ret->sum = (ret->le->sum + ret->ri->sum) % 1000000000;
  }
  return ret;
}
inline void up(Node *nd) { nd->sum = (nd->le->sum + nd->ri->sum) % 1000000000; }
inline void del1(Node *nd, long long int dd) {
  nd->del = (nd->del + dd) % 1000000000;
  nd->sum = (nd->sum + dd * nd->base % 1000000000) % 1000000000;
}
inline void down(Node *nd) {
  if (nd->del) {
    del1(nd->le, nd->del);
    del1(nd->ri, nd->del);
    nd->del = 0;
  }
}
int Xl, Xr;
long long int Xv;
void cha(Node *nd, int l, int r) {
  if (l == r) {
    nd->sum = Xv * nd->base % 1000000000;
    return;
  }
  int m = l + r >> 1;
  down(nd);
  if (Xl <= m)
    cha(nd->le, l, m);
  else
    cha(nd->ri, m + 1, r);
  up(nd);
}
void jia(Node *nd, int l, int r) {
  if (l > Xr || r < Xl) return;
  if (l >= Xl && r <= Xr) {
    del1(nd, Xv);
    return;
  }
  int m = l + r >> 1;
  down(nd);
  jia(nd->le, l, m);
  jia(nd->ri, m + 1, r);
  up(nd);
}
long long int quer(Node *nd, int l, int r) {
  if (l > Xr || r < Xl) return 0;
  if (l >= Xl && r <= Xr) return nd->sum;
  int m = l + r >> 1;
  down(nd);
  return (quer(nd->le, l, m) + quer(nd->ri, m + 1, r)) % 1000000000;
}
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  f[-1] = 1;
  f[0] = 0;
  for (i = 1; i <= n + 2; i++) f[i] = (f[i - 1] + f[i - 2]) % 1000000000;
  for (i = 1; i <= n; i++) scanf("%I64d", ff + i);
  g = f;
  A = buildtree(1, n);
  g = f - 1;
  B = buildtree(1, n);
  for (i = -1; i <= n + 2; i++)
    if (i & 1)
      ff[i] = f[i];
    else
      ff[i] = (1000000000 - f[i]) % 1000000000;
  int cmd;
  long long int ans;
  for (i = 1; i <= m; i++) {
    scanf("%d", &cmd);
    if (cmd == 1) {
      scanf("%d%I64d", &Xl, &Xv);
      cha(A, 1, n);
      cha(B, 1, n);
    }
    if (cmd == 2) {
      scanf("%d%d", &Xl, &Xr);
      ans = (ff[Xl - 2] * quer(A, 1, n) % 1000000000 +
             ff[Xl - 1] * quer(B, 1, n) % 1000000000) %
            1000000000;
      printf("%I64d\n", ans);
    }
    if (cmd == 3) {
      scanf("%d%d%I64d", &Xl, &Xr, &Xv);
      jia(A, 1, n);
      jia(B, 1, n);
    }
  }
  return 0;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

By the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher:

You are given a sequence of integers a1, a2, ..., an. Your task is to perform on it m consecutive operations of the following type:

  1. For given numbers xi and vi assign value vi to element axi. 
  2. For given numbers li and ri you've got to calculate sum <image>, where f0 = f1 = 1 and at i ≥ 2: fi = fi - 1 + fi - 2. 
  3. For a group of three numbers li ri di you should increase value ax by di for all x (li ≤ x ≤ ri). 



Smart Beaver planned a tour around great Canadian lakes, so he asked you to help him solve the given problem.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2·105) — the number of integers in the sequence and the number of operations, correspondingly. The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 105). Then follow m lines, each describes an operation. Each line starts with an integer ti (1 ≤ ti ≤ 3) — the operation type: 

  * if ti = 1, then next follow two integers xi vi (1 ≤ xi ≤ n, 0 ≤ vi ≤ 105); 
  * if ti = 2, then next follow two integers li ri (1 ≤ li ≤ ri ≤ n); 
  * if ti = 3, then next follow three integers li ri di (1 ≤ li ≤ ri ≤ n, 0 ≤ di ≤ 105). 



The input limits for scoring 30 points are (subproblem E1): 

  * It is guaranteed that n does not exceed 100, m does not exceed 10000 and there will be no queries of the 3-rd type. 



The input limits for scoring 70 points are (subproblems E1+E2): 

  * It is guaranteed that there will be queries of the 1-st and 2-nd type only. 



The input limits for scoring 100 points are (subproblems E1+E2+E3): 

  * No extra limitations. 

Output

For each query print the calculated sum modulo 1000000000 (109).

Examples

Input

5 5
1 3 1 2 4
2 1 4
2 1 5
2 2 4
1 3 10
2 1 5


Output

12
32
8
50


Input

5 4
1 3 1 2 4
3 1 4 1
2 2 4
1 2 10
2 1 5


Output

12
45

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long int arr[262144 << 1];
arr aa, bb;
long long int *f = aa + 1;
long long int *ff = bb + 1;
long long int *g;
struct Node {
  Node *le, *ri;
  long long int del, sum, base;
  Node() : le(0), ri(0), del(0), sum(0), base(0) {}
} * A, *B;
Node *buildtree(int l, int r) {
  Node *ret = new Node();
  if (l == r) {
    ret->base = g[l];
    ret->sum = g[l] * ff[l] % 1000000000;
  } else {
    int m = l + r >> 1;
    ret->le = buildtree(l, m);
    ret->ri = buildtree(m + 1, r);
    ret->base = (ret->le->base + ret->ri->base) % 1000000000;
    ret->sum = (ret->le->sum + ret->ri->sum) % 1000000000;
  }
  return ret;
}
inline void up(Node *nd) { nd->sum = (nd->le->sum + nd->ri->sum) % 1000000000; }
inline void del1(Node *nd, long long int dd) {
  nd->del = (nd->del + dd) % 1000000000;
  nd->sum = (nd->sum + dd * nd->base % 1000000000) % 1000000000;
}
inline void down(Node *nd) {
  if (nd->del) {
    del1(nd->le, nd->del);
    del1(nd->ri, nd->del);
    nd->del = 0;
  }
}
int Xl, Xr;
long long int Xv;
void cha(Node *nd, int l, int r) {
  if (l == r) {
    nd->sum = Xv * nd->base % 1000000000;
    return;
  }
  int m = l + r >> 1;
  down(nd);
  if (Xl <= m)
    cha(nd->le, l, m);
  else
    cha(nd->ri, m + 1, r);
  up(nd);
}
void jia(Node *nd, int l, int r) {
  if (l > Xr || r < Xl) return;
  if (l >= Xl && r <= Xr) {
    del1(nd, Xv);
    return;
  }
  int m = l + r >> 1;
  down(nd);
  jia(nd->le, l, m);
  jia(nd->ri, m + 1, r);
  up(nd);
}
long long int quer(Node *nd, int l, int r) {
  if (l > Xr || r < Xl) return 0;
  if (l >= Xl && r <= Xr) return nd->sum;
  int m = l + r >> 1;
  down(nd);
  return (quer(nd->le, l, m) + quer(nd->ri, m + 1, r)) % 1000000000;
}
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  f[-1] = 1;
  f[0] = 0;
  for (i = 1; i <= n + 2; i++) f[i] = (f[i - 1] + f[i - 2]) % 1000000000;
  for (i = 1; i <= n; i++) scanf("%I64d", ff + i);
  g = f;
  A = buildtree(1, n);
  g = f - 1;
  B = buildtree(1, n);
  for (i = -1; i <= n + 2; i++)
    if (i & 1)
      ff[i] = f[i];
    else
      ff[i] = (1000000000 - f[i]) % 1000000000;
  int cmd;
  long long int ans;
  for (i = 1; i <= m; i++) {
    scanf("%d", &cmd);
    if (cmd == 1) {
      scanf("%d%I64d", &Xl, &Xv);
      cha(A, 1, n);
      cha(B, 1, n);
    }
    if (cmd == 2) {
      scanf("%d%d", &Xl, &Xr);
      ans = (ff[Xl - 2] * quer(A, 1, n) % 1000000000 +
             ff[Xl - 1] * quer(B, 1, n) % 1000000000) %
            1000000000;
      printf("%I64d\n", ans);
    }
    if (cmd == 3) {
      scanf("%d%d%I64d", &Xl, &Xr, &Xv);
      jia(A, 1, n);
      jia(B, 1, n);
    }
  }
  return 0;
}

```