#include <bits/stdc++.h>
using namespace std;
const int maxN = 200 * 1000 + 5;
const int mod = 1000 * 1000 * 1000;
int fib[maxN], pf[maxN];
int a[maxN];
int seg1[4 * maxN], seg2[4 * maxN];
int ad[4 * maxN];
int change(int x, int y, int lev) {
  return ((1LL) * x * fib[lev] + (1LL) * y * fib[lev + 1]) % mod;
}
void eval(int ind, int val, int s, int e) {
  seg1[ind] += (1LL) * val * pf[e - s - 1] % mod;
  seg2[ind] += (1LL) * val * pf[e - s - 0] % mod;
  if (seg1[ind] >= mod) seg1[ind] -= mod;
  if (seg2[ind] >= mod) seg2[ind] -= mod;
}
void shift(int ind, int s, int e) {
  int mid = (s + e) >> 1;
  eval(2 * ind + 0, ad[ind], s, mid);
  eval(2 * ind + 1, ad[ind], mid, e);
  ad[2 * ind + 0] += ad[ind];
  ad[2 * ind + 1] += ad[ind];
  ad[ind] = 0;
  if (ad[2 * ind + 0] >= mod) ad[2 * ind + 0] -= mod;
  if (ad[2 * ind + 1] >= mod) ad[2 * ind + 1] -= mod;
}
void update(int ind, int s, int e) {
  int mid = (s + e) >> 1;
  seg1[ind] = seg2[ind] = 0;
  seg1[ind] =
      seg1[2 * ind] + change(seg1[2 * ind + 1], seg2[2 * ind + 1], mid - s - 1);
  seg2[ind] =
      seg2[2 * ind] + change(seg1[2 * ind + 1], seg2[2 * ind + 1], mid - s - 0);
  if (seg1[ind] >= mod) seg1[ind] -= mod;
  if (seg2[ind] >= mod) seg2[ind] -= mod;
}
void build(int s, int e, int ind) {
  if (e - s == 1) {
    seg1[ind] = 0;
    seg2[ind] = a[s];
    return;
  }
  int mid = (s + e) >> 1;
  build(s, mid, 2 * ind + 0);
  build(mid, e, 2 * ind + 1);
  update(ind, s, e);
}
void add(int p, int val, int s, int e, int ind) {
  if (e - s == 1) {
    seg1[ind] = 0;
    seg2[ind] = val;
    ad[ind] = 0;
    return;
  }
  int mid = (s + e) >> 1;
  shift(ind, s, e);
  if (p < mid)
    add(p, val, s, mid, 2 * ind);
  else
    add(p, val, mid, e, 2 * ind + 1);
  update(ind, s, e);
}
void mak(int l, int r, int val, int s, int e, int ind) {
  if (l >= e || r <= s) return;
  if (l <= s && e <= r) {
    ad[ind] += val;
    eval(ind, val, s, e);
    if (ad[ind] >= mod) ad[ind] -= mod;
    return;
  }
  shift(ind, s, e);
  int mid = (s + e) >> 1;
  mak(l, r, val, s, mid, 2 * ind + 0);
  mak(l, r, val, mid, e, 2 * ind + 1);
  update(ind, s, e);
}
int get(int l, int r, int s, int e, int ind) {
  if (l >= e || r <= s) return 0;
  if (l <= s && e <= r) {
    int ans = change(seg1[ind], seg2[ind], s - l);
    return ans;
  }
  shift(ind, s, e);
  int mid = (s + e) >> 1;
  int x = get(l, r, s, mid, 2 * ind + 0);
  int y = get(l, r, mid, e, 2 * ind + 1);
  update(ind, s, e);
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  fib[0] = 0;
  fib[1] = 1;
  pf[0] = 0;
  pf[1] = 1;
  for (int i = 2; i < maxN; i++) {
    fib[i] = fib[i - 1] + fib[i - 2];
    pf[i] = pf[i - 1] + fib[i];
    if (fib[i] >= mod) fib[i] -= mod;
    if (pf[i] >= mod) pf[i] -= mod;
  }
  build(0, n, 1);
  for (int i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x, v;
      scanf("%d%d", &x, &v);
      x--;
      add(x, v, 0, n, 1);
    }
    if (t == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      printf("%d\n", get(l, r, 0, n, 1));
    }
    if (t == 3) {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      l--;
      mak(l, r, d, 0, n, 1);
    }
  }
  return 0;
}

### Prompt

Your task is to create 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;
const int maxN = 200 * 1000 + 5;
const int mod = 1000 * 1000 * 1000;
int fib[maxN], pf[maxN];
int a[maxN];
int seg1[4 * maxN], seg2[4 * maxN];
int ad[4 * maxN];
int change(int x, int y, int lev) {
  return ((1LL) * x * fib[lev] + (1LL) * y * fib[lev + 1]) % mod;
}
void eval(int ind, int val, int s, int e) {
  seg1[ind] += (1LL) * val * pf[e - s - 1] % mod;
  seg2[ind] += (1LL) * val * pf[e - s - 0] % mod;
  if (seg1[ind] >= mod) seg1[ind] -= mod;
  if (seg2[ind] >= mod) seg2[ind] -= mod;
}
void shift(int ind, int s, int e) {
  int mid = (s + e) >> 1;
  eval(2 * ind + 0, ad[ind], s, mid);
  eval(2 * ind + 1, ad[ind], mid, e);
  ad[2 * ind + 0] += ad[ind];
  ad[2 * ind + 1] += ad[ind];
  ad[ind] = 0;
  if (ad[2 * ind + 0] >= mod) ad[2 * ind + 0] -= mod;
  if (ad[2 * ind + 1] >= mod) ad[2 * ind + 1] -= mod;
}
void update(int ind, int s, int e) {
  int mid = (s + e) >> 1;
  seg1[ind] = seg2[ind] = 0;
  seg1[ind] =
      seg1[2 * ind] + change(seg1[2 * ind + 1], seg2[2 * ind + 1], mid - s - 1);
  seg2[ind] =
      seg2[2 * ind] + change(seg1[2 * ind + 1], seg2[2 * ind + 1], mid - s - 0);
  if (seg1[ind] >= mod) seg1[ind] -= mod;
  if (seg2[ind] >= mod) seg2[ind] -= mod;
}
void build(int s, int e, int ind) {
  if (e - s == 1) {
    seg1[ind] = 0;
    seg2[ind] = a[s];
    return;
  }
  int mid = (s + e) >> 1;
  build(s, mid, 2 * ind + 0);
  build(mid, e, 2 * ind + 1);
  update(ind, s, e);
}
void add(int p, int val, int s, int e, int ind) {
  if (e - s == 1) {
    seg1[ind] = 0;
    seg2[ind] = val;
    ad[ind] = 0;
    return;
  }
  int mid = (s + e) >> 1;
  shift(ind, s, e);
  if (p < mid)
    add(p, val, s, mid, 2 * ind);
  else
    add(p, val, mid, e, 2 * ind + 1);
  update(ind, s, e);
}
void mak(int l, int r, int val, int s, int e, int ind) {
  if (l >= e || r <= s) return;
  if (l <= s && e <= r) {
    ad[ind] += val;
    eval(ind, val, s, e);
    if (ad[ind] >= mod) ad[ind] -= mod;
    return;
  }
  shift(ind, s, e);
  int mid = (s + e) >> 1;
  mak(l, r, val, s, mid, 2 * ind + 0);
  mak(l, r, val, mid, e, 2 * ind + 1);
  update(ind, s, e);
}
int get(int l, int r, int s, int e, int ind) {
  if (l >= e || r <= s) return 0;
  if (l <= s && e <= r) {
    int ans = change(seg1[ind], seg2[ind], s - l);
    return ans;
  }
  shift(ind, s, e);
  int mid = (s + e) >> 1;
  int x = get(l, r, s, mid, 2 * ind + 0);
  int y = get(l, r, mid, e, 2 * ind + 1);
  update(ind, s, e);
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  fib[0] = 0;
  fib[1] = 1;
  pf[0] = 0;
  pf[1] = 1;
  for (int i = 2; i < maxN; i++) {
    fib[i] = fib[i - 1] + fib[i - 2];
    pf[i] = pf[i - 1] + fib[i];
    if (fib[i] >= mod) fib[i] -= mod;
    if (pf[i] >= mod) pf[i] -= mod;
  }
  build(0, n, 1);
  for (int i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x, v;
      scanf("%d%d", &x, &v);
      x--;
      add(x, v, 0, n, 1);
    }
    if (t == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      printf("%d\n", get(l, r, 0, n, 1));
    }
    if (t == 3) {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      l--;
      mak(l, r, d, 0, n, 1);
    }
  }
  return 0;
}

```