#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000000;
const int MAXN = 200110;
int n, m;
int a[MAXN];
int fib[MAXN];
int rfib[MAXN];
int lazy[2][MAXN * 4];
int tree[2][MAXN * 4];
void pushdown(int id, int pos) {}
void update(int id, int l, int r, int x, int v, int pos) {
  pushdown(id, pos);
  if (l == r)
    tree[id][pos] = (tree[id][pos] + v) % MOD;
  else {
    int mid = (l + r) >> 1;
    if (x <= mid)
      update(id, l, mid, x, v, pos * 2);
    else
      update(id, mid + 1, r, x, v, pos * 2 + 1);
    tree[id][pos] = (tree[id][pos * 2] + tree[id][pos * 2 + 1]) % MOD;
  }
}
void update(int id, int x, int v) { update(id, 1, n, x, v, 1); }
int read(int id, int l, int r, int ql, int qr, int pos) {
  pushdown(id, pos);
  if (ql <= l && r <= qr)
    return tree[id][pos];
  else {
    int mid = (l + r) >> 1;
    int ret = 0;
    if (ql <= mid) ret = read(id, l, mid, ql, qr, pos * 2);
    if (qr > mid) ret = (ret + read(id, mid + 1, r, ql, qr, pos * 2 + 1)) % MOD;
    return ret;
  }
}
int read(int id, int l, int r) { return read(id, 1, n, l, r, 1); }
int main() {
  fib[0] = fib[1] = 1;
  for (int i = 2; i < MAXN; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % MOD;
  rfib[0] = 1;
  rfib[1] = MOD - 1;
  for (int i = 2; i < MAXN; i++)
    rfib[i] = (rfib[i - 2] - rfib[i - 1] + MOD) % MOD;
  memset(lazy, 0, sizeof(lazy));
  memset(tree, 0, sizeof(tree));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(0, i, (long long)a[i] * fib[i - 1] % MOD);
    update(1, i, (long long)a[i] * fib[i] % MOD);
  }
  for (int q = 0; q < m; q++) {
    int typ;
    scanf("%d", &typ);
    if (typ == 1) {
      int x, v;
      scanf("%d%d", &x, &v);
      update(0, x, MOD - read(0, x, x));
      update(0, x, (long long)v * fib[x - 1] % MOD);
      update(1, x, MOD - read(1, x, x));
      update(1, x, (long long)v * fib[x] % MOD);
    } else if (typ == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      int sum0 = read(0, l, r);
      int sum1 = read(1, l, r);
      if (l == 1)
        printf("%d\n", sum0);
      else if (l == 2)
        printf("%d\n", (sum1 - sum0 + MOD) % MOD);
      else {
        int ans = (long long)sum1 * rfib[l - 2] % MOD +
                  (long long)sum0 * rfib[l - 1] % MOD;
        ans = ans % MOD;
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}

### Prompt

In Cpp, your task is to solve 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 MOD = 1000000000;
const int MAXN = 200110;
int n, m;
int a[MAXN];
int fib[MAXN];
int rfib[MAXN];
int lazy[2][MAXN * 4];
int tree[2][MAXN * 4];
void pushdown(int id, int pos) {}
void update(int id, int l, int r, int x, int v, int pos) {
  pushdown(id, pos);
  if (l == r)
    tree[id][pos] = (tree[id][pos] + v) % MOD;
  else {
    int mid = (l + r) >> 1;
    if (x <= mid)
      update(id, l, mid, x, v, pos * 2);
    else
      update(id, mid + 1, r, x, v, pos * 2 + 1);
    tree[id][pos] = (tree[id][pos * 2] + tree[id][pos * 2 + 1]) % MOD;
  }
}
void update(int id, int x, int v) { update(id, 1, n, x, v, 1); }
int read(int id, int l, int r, int ql, int qr, int pos) {
  pushdown(id, pos);
  if (ql <= l && r <= qr)
    return tree[id][pos];
  else {
    int mid = (l + r) >> 1;
    int ret = 0;
    if (ql <= mid) ret = read(id, l, mid, ql, qr, pos * 2);
    if (qr > mid) ret = (ret + read(id, mid + 1, r, ql, qr, pos * 2 + 1)) % MOD;
    return ret;
  }
}
int read(int id, int l, int r) { return read(id, 1, n, l, r, 1); }
int main() {
  fib[0] = fib[1] = 1;
  for (int i = 2; i < MAXN; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % MOD;
  rfib[0] = 1;
  rfib[1] = MOD - 1;
  for (int i = 2; i < MAXN; i++)
    rfib[i] = (rfib[i - 2] - rfib[i - 1] + MOD) % MOD;
  memset(lazy, 0, sizeof(lazy));
  memset(tree, 0, sizeof(tree));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(0, i, (long long)a[i] * fib[i - 1] % MOD);
    update(1, i, (long long)a[i] * fib[i] % MOD);
  }
  for (int q = 0; q < m; q++) {
    int typ;
    scanf("%d", &typ);
    if (typ == 1) {
      int x, v;
      scanf("%d%d", &x, &v);
      update(0, x, MOD - read(0, x, x));
      update(0, x, (long long)v * fib[x - 1] % MOD);
      update(1, x, MOD - read(1, x, x));
      update(1, x, (long long)v * fib[x] % MOD);
    } else if (typ == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      int sum0 = read(0, l, r);
      int sum1 = read(1, l, r);
      if (l == 1)
        printf("%d\n", sum0);
      else if (l == 2)
        printf("%d\n", (sum1 - sum0 + MOD) % MOD);
      else {
        int ans = (long long)sum1 * rfib[l - 2] % MOD +
                  (long long)sum0 * rfib[l - 1] % MOD;
        ans = ans % MOD;
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}

```