#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
long long f[200011];
long long a[200011];
int n, m;
long long T1[200011 * 4], T2[200011 * 4], T3[200011 * 4];
void init() {
  f[0] = f[1] = 1;
  for (int i = (2), _b = (200000); i <= _b; i++)
    f[i] = (f[i - 1] + f[i - 2]) % 1000000000;
}
void update(int k, int l, int r, int i, long long x) {
  if (l > i || r < i) return;
  if (r - l + 1 <= 5) {
    long long res1 = 0, res2 = 0, res3 = 0, s;
    for (int j = (l), _b = (r); j <= _b; j++) {
      if (j == i)
        s = x;
      else
        s = a[j];
      res1 = (res1 + f[j - l] * s) % 1000000000;
      if (j - l >= 2) res2 = (res2 + f[j - l - 2] * s) % 1000000000;
      if (j - l >= 1) res3 = (res3 + f[j - l - 1] * s) % 1000000000;
    }
    T1[k] = res1;
    T2[k] = res2;
    T3[k] = res3;
    return;
  }
  int m = (l + r) / 2;
  update(k * 2, l, m, i, x);
  update(k * 2 + 1, m + 1, r, i, x);
  T1[k] = (T1[k] + (x - a[i]) * f[i - l]) % 1000000000;
  if (i - l >= 2) T2[k] = (T2[k] + (x - a[i]) * f[i - l - 2]) % 1000000000;
  if (i - l >= 1) T3[k] = (T3[k] + (x - a[i]) * f[i - l - 1]) % 1000000000;
}
long long get(int k, int l, int r, int i, int j) {
  if (l > j || r < i) return 0;
  if (i <= l && j >= r) {
    if (r - l + 1 <= 5) {
      long long res = 0;
      for (int t = (l), _b = (r); t <= _b; t++) {
        res = (res + f[t - i] * a[t]) % 1000000000;
      }
      return res;
    }
    long long res = T1[k];
    long long x2 = f[l - i] - 1;
    long long x3 = f[l + 1 - i] - 1;
    res = (res + T2[k] * x2 + T3[k] * x3 + x2 * a[l]) % 1000000000;
    return res;
  }
  int m = (l + r) / 2;
  return (get(k * 2, l, m, i, j) + get(k * 2 + 1, m + 1, r, i, j)) % 1000000000;
}
long long tinh(int l, int r) {
  long long res = 0;
  for (int i = (l), _b = (r); i <= _b; i++)
    res = (res + f[i - l] * a[i]) % 1000000000;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  init();
  for (int i = (1), _b = (n); i <= _b; i++) {
    int x;
    cin >> x;
    update(1, 1, n, i, x);
    a[i] = x;
  }
  while (m--) {
    int i, x, type, l, r;
    cin >> type;
    if (type == 1) {
      cin >> i >> x;
      update(1, 1, n, i, x);
      a[i] = x;
    } else {
      cin >> l >> r;
      long long res = get(1, 1, n, l, r);
      cout << (res + 1000000000) % 1000000000 << endl;
    }
  }
  return 0;
}

### Prompt

Create a solution in cpp for 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>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
long long f[200011];
long long a[200011];
int n, m;
long long T1[200011 * 4], T2[200011 * 4], T3[200011 * 4];
void init() {
  f[0] = f[1] = 1;
  for (int i = (2), _b = (200000); i <= _b; i++)
    f[i] = (f[i - 1] + f[i - 2]) % 1000000000;
}
void update(int k, int l, int r, int i, long long x) {
  if (l > i || r < i) return;
  if (r - l + 1 <= 5) {
    long long res1 = 0, res2 = 0, res3 = 0, s;
    for (int j = (l), _b = (r); j <= _b; j++) {
      if (j == i)
        s = x;
      else
        s = a[j];
      res1 = (res1 + f[j - l] * s) % 1000000000;
      if (j - l >= 2) res2 = (res2 + f[j - l - 2] * s) % 1000000000;
      if (j - l >= 1) res3 = (res3 + f[j - l - 1] * s) % 1000000000;
    }
    T1[k] = res1;
    T2[k] = res2;
    T3[k] = res3;
    return;
  }
  int m = (l + r) / 2;
  update(k * 2, l, m, i, x);
  update(k * 2 + 1, m + 1, r, i, x);
  T1[k] = (T1[k] + (x - a[i]) * f[i - l]) % 1000000000;
  if (i - l >= 2) T2[k] = (T2[k] + (x - a[i]) * f[i - l - 2]) % 1000000000;
  if (i - l >= 1) T3[k] = (T3[k] + (x - a[i]) * f[i - l - 1]) % 1000000000;
}
long long get(int k, int l, int r, int i, int j) {
  if (l > j || r < i) return 0;
  if (i <= l && j >= r) {
    if (r - l + 1 <= 5) {
      long long res = 0;
      for (int t = (l), _b = (r); t <= _b; t++) {
        res = (res + f[t - i] * a[t]) % 1000000000;
      }
      return res;
    }
    long long res = T1[k];
    long long x2 = f[l - i] - 1;
    long long x3 = f[l + 1 - i] - 1;
    res = (res + T2[k] * x2 + T3[k] * x3 + x2 * a[l]) % 1000000000;
    return res;
  }
  int m = (l + r) / 2;
  return (get(k * 2, l, m, i, j) + get(k * 2 + 1, m + 1, r, i, j)) % 1000000000;
}
long long tinh(int l, int r) {
  long long res = 0;
  for (int i = (l), _b = (r); i <= _b; i++)
    res = (res + f[i - l] * a[i]) % 1000000000;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  init();
  for (int i = (1), _b = (n); i <= _b; i++) {
    int x;
    cin >> x;
    update(1, 1, n, i, x);
    a[i] = x;
  }
  while (m--) {
    int i, x, type, l, r;
    cin >> type;
    if (type == 1) {
      cin >> i >> x;
      update(1, 1, n, i, x);
      a[i] = x;
    } else {
      cin >> l >> r;
      long long res = get(1, 1, n, l, r);
      cout << (res + 1000000000) % 1000000000 << endl;
    }
  }
  return 0;
}

```