#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:32505856")
template <class T>
inline T sqr(T a) {
  return a * a;
}
template <class T>
inline void gmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void gmax(T &a, T b) {
  if (a < b) a = b;
}
inline int sign(const double &a) { return a > 1e-9 ? 1 : (a < -1e-9 ? -1 : 0); }
struct Initializer {
  Initializer() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  ~Initializer() {}
} initializer;
int a[200010];
long long f[200010] = {1, 1}, sumf[200010] = {1, 2};
int P, Q;
long long V;
long long t1[400020], t2[400020];
void build(int l, int r) {
  int first = ((l + r) | (l != r));
  for (int i = l; i <= r; i++) {
    (t1[first] += f[i - l] * a[i] % 1000000000) %= 1000000000;
    if (i > l) (t2[first] += f[i - l - 1] * a[i] % 1000000000) %= 1000000000;
  }
  if (l == r) return;
  int m = l + r >> 1;
  build(l, m);
  build(m + 1, r);
}
void select(int l, int r) {
  int first = ((l + r) | (l != r));
  if (P <= l && r <= Q) {
    if (l == P)
      V = (V + t1[first]) % 1000000000;
    else {
      V = (V + f[l - P] * t1[first] % 1000000000) % 1000000000;
      V = (V + f[l - P - 1] * t2[first] % 1000000000) % 1000000000;
    }
    return;
  }
  int m = l + r >> 1;
  if (P <= m) select(l, m);
  if (Q > m) select(m + 1, r);
}
void modify(int l, int r) {
  int first = ((l + r) | (l != r));
  t1[first] = (t1[first] + f[P - l] * (V - a[P]) % 1000000000 + 1000000000) %
              1000000000;
  if (l != P)
    t2[first] =
        (t2[first] + f[P - l - 1] * (V - a[P]) % 1000000000 + 1000000000) %
        1000000000;
  if (l == r) return;
  int m = l + r >> 1;
  if (P <= m)
    modify(l, m);
  else
    modify(m + 1, r);
}
void increase(int l, int r) {
  int first = ((l + r) | (l != r));
  if (P <= l && r <= Q) {
    t1[first] = (t1[first] + sumf[r - l] * V % 1000000000) % 1000000000;
    if (l < r)
      t2[first] = (t2[first] + sumf[r - l - 1] * V % 1000000000) % 1000000000;
    return;
  }
  int m = l + r >> 1;
  if (P <= m) increase(l, m);
  if (Q > m) increase(m + 1, r);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 2; i <= n; i++) {
    f[i] = (f[i - 1] + f[i - 2]) % 1000000000;
    sumf[i] = (sumf[i - 1] + f[i]) % 1000000000;
  }
  build(1, n);
  for (int i = 1; i <= m; i++) {
    int k, first, second, d;
    scanf("%d%d%d", &k, &first, &second);
    if (k == 1) {
      P = first, V = second;
      modify(1, n);
      a[P] = V;
    } else if (k == 2) {
      P = first, Q = second, V = 0;
      select(1, n);
      printf("%d\n", (int)V);
    } else if (k == 3) {
      scanf("%d", &d);
      P = first, Q = second, V = d;
      increase(1, n);
    }
  }
  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;
#pragma comment(linker, "/STACK:32505856")
template <class T>
inline T sqr(T a) {
  return a * a;
}
template <class T>
inline void gmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void gmax(T &a, T b) {
  if (a < b) a = b;
}
inline int sign(const double &a) { return a > 1e-9 ? 1 : (a < -1e-9 ? -1 : 0); }
struct Initializer {
  Initializer() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  ~Initializer() {}
} initializer;
int a[200010];
long long f[200010] = {1, 1}, sumf[200010] = {1, 2};
int P, Q;
long long V;
long long t1[400020], t2[400020];
void build(int l, int r) {
  int first = ((l + r) | (l != r));
  for (int i = l; i <= r; i++) {
    (t1[first] += f[i - l] * a[i] % 1000000000) %= 1000000000;
    if (i > l) (t2[first] += f[i - l - 1] * a[i] % 1000000000) %= 1000000000;
  }
  if (l == r) return;
  int m = l + r >> 1;
  build(l, m);
  build(m + 1, r);
}
void select(int l, int r) {
  int first = ((l + r) | (l != r));
  if (P <= l && r <= Q) {
    if (l == P)
      V = (V + t1[first]) % 1000000000;
    else {
      V = (V + f[l - P] * t1[first] % 1000000000) % 1000000000;
      V = (V + f[l - P - 1] * t2[first] % 1000000000) % 1000000000;
    }
    return;
  }
  int m = l + r >> 1;
  if (P <= m) select(l, m);
  if (Q > m) select(m + 1, r);
}
void modify(int l, int r) {
  int first = ((l + r) | (l != r));
  t1[first] = (t1[first] + f[P - l] * (V - a[P]) % 1000000000 + 1000000000) %
              1000000000;
  if (l != P)
    t2[first] =
        (t2[first] + f[P - l - 1] * (V - a[P]) % 1000000000 + 1000000000) %
        1000000000;
  if (l == r) return;
  int m = l + r >> 1;
  if (P <= m)
    modify(l, m);
  else
    modify(m + 1, r);
}
void increase(int l, int r) {
  int first = ((l + r) | (l != r));
  if (P <= l && r <= Q) {
    t1[first] = (t1[first] + sumf[r - l] * V % 1000000000) % 1000000000;
    if (l < r)
      t2[first] = (t2[first] + sumf[r - l - 1] * V % 1000000000) % 1000000000;
    return;
  }
  int m = l + r >> 1;
  if (P <= m) increase(l, m);
  if (Q > m) increase(m + 1, r);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 2; i <= n; i++) {
    f[i] = (f[i - 1] + f[i - 2]) % 1000000000;
    sumf[i] = (sumf[i - 1] + f[i]) % 1000000000;
  }
  build(1, n);
  for (int i = 1; i <= m; i++) {
    int k, first, second, d;
    scanf("%d%d%d", &k, &first, &second);
    if (k == 1) {
      P = first, V = second;
      modify(1, n);
      a[P] = V;
    } else if (k == 2) {
      P = first, Q = second, V = 0;
      select(1, n);
      printf("%d\n", (int)V);
    } else if (k == 3) {
      scanf("%d", &d);
      P = first, Q = second, V = d;
      increase(1, n);
    }
  }
  return 0;
}

```