#include <bits/stdc++.h>
using namespace std;
class KD {
 public:
  long long s, s0, s1, size;
  KD() { s = s0 = s1 = size = 0; }
  KD(long long a, long long b, long long c) {
    s0 = a;
    s1 = b;
    size = c;
  }
} ST[4 * 200005];
KD make_kd(long long a, long long b, long long c) {
  KD I(a, b, c);
  return I;
}
int M, N;
long long A[200005], Fib[200005], S[200005];
void init_Fib() {
  Fib[0] = Fib[1] = 1;
  int i;
  for (i = 2; i <= N; i++) Fib[i] = (Fib[i - 1] + Fib[i - 2]) % 1000000000;
  S[0] = 1;
  for (i = 1; i <= N; i++) S[i] = (S[i - 1] + Fib[i]) % 1000000000;
}
long long hesapla(long long s0, long long s1, int n) {
  if (!n) return s0;
  if (n == 1) return s1;
  return (Fib[n - 1] * s1 + Fib[n - 2] * s0) % 1000000000;
}
long long f(int a, int b, int x) {
  long long s(0);
  int i;
  for (i = a; i <= b; i++) s = (s + A[i] * Fib[x++]) % 1000000000;
  return s;
}
void init(int pos, int s, int e) {
  ST[pos].s0 = f(s, e, 0);
  ST[pos].s1 = f(s, e, 1);
  if (s == e) return;
  int m = (s + e) >> 1;
  init(pos << 1, s, m);
  init((pos << 1) + 1, m + 1, e);
}
KD update1(int pos, int s, int e, int a, long long v) {
  if (a < s || a > e) return ST[pos];
  if (s == e) return ST[pos] = make_kd(v, v, 0);
  int m = (s + e) >> 1;
  int k = e - s + 1;
  KD p1 = update1(pos << 1, s, m, a, v);
  KD p2 = update1((pos << 1) + 1, m + 1, e, a, v);
  ST[pos].s0 =
      (p1.s0 + hesapla(p2.s0, p2.s1, m - s + 1) + ST[pos].s * S[k - 1]) %
      1000000000;
  ST[pos].s1 =
      (p1.s1 + hesapla(p2.s0, p2.s1, m - s + 2) + ST[pos].s * (S[k] - 1)) %
      1000000000;
  return ST[pos];
}
KD update2(int pos, int s, int e, int a, int b, long long v) {
  if (a > e || b < s) return ST[pos];
  int k = e - s + 1;
  if (a <= s && e <= b) {
    ST[pos].s = (ST[pos].s + v) % 1000000000;
    ST[pos].s0 = (ST[pos].s0 + v * S[k - 1]) % 1000000000;
    ST[pos].s1 = (ST[pos].s1 + v * (S[k] - 1)) % 1000000000;
    return ST[pos];
  }
  int m = (s + e) >> 1;
  KD p1 = update2(pos << 1, s, m, a, b, v);
  KD p2 = update2((pos << 1) + 1, m + 1, e, a, b, v);
  ST[pos].s0 =
      (p1.s0 + hesapla(p2.s0, p2.s1, m - s + 1) + ST[pos].s * S[k - 1]) %
      1000000000;
  ST[pos].s1 =
      (p1.s1 + hesapla(p2.s0, p2.s1, m - s + 2) + ST[pos].s * (S[k] - 1)) %
      1000000000;
  return ST[pos];
}
KD find(int pos, int s, int e, int a, int b, long long syc) {
  if (a > e || b < s) return make_kd(0, 0, 0);
  int k = e - s + 1;
  if (a <= s && e <= b)
    return make_kd((ST[pos].s0 + syc * S[k - 1]) % 1000000000,
                   (ST[pos].s1 + syc * (S[k] - 1)) % 1000000000, k);
  int m = (s + e) >> 1;
  KD p1 = find(pos << 1, s, m, a, b, (syc + ST[pos].s) % 1000000000);
  KD p2 = find((pos << 1) + 1, m + 1, e, a, b, (syc + ST[pos].s) % 1000000000);
  KD res;
  res.size = p1.size + p2.size;
  res.s0 = (p1.s0 + hesapla(p2.s0, p2.s1, p1.size)) % 1000000000;
  res.s1 = (p1.s1 + hesapla(p2.s0, p2.s1, p1.size + 1)) % 1000000000;
  return res;
}
void solve() {
  int a, b, i, k;
  long long v;
  scanf("%d %d", &N, &M);
  init_Fib();
  for (i = 1; i <= N; i++) scanf("%lld", A + i);
  init(1, 1, N);
  for (i = 1; i <= M; i++) {
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d %lld", &a, &v);
      update1(1, 1, N, a, v);
    } else if (k == 2) {
      scanf("%d %d", &a, &b);
      printf("%lld\n", find(1, 1, N, a, b, 0).s0);
    } else {
      scanf("%d %d %lld", &a, &b, &v);
      update2(1, 1, N, a, b, v);
    }
  }
}
int main() {
  solve();
  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>
using namespace std;
class KD {
 public:
  long long s, s0, s1, size;
  KD() { s = s0 = s1 = size = 0; }
  KD(long long a, long long b, long long c) {
    s0 = a;
    s1 = b;
    size = c;
  }
} ST[4 * 200005];
KD make_kd(long long a, long long b, long long c) {
  KD I(a, b, c);
  return I;
}
int M, N;
long long A[200005], Fib[200005], S[200005];
void init_Fib() {
  Fib[0] = Fib[1] = 1;
  int i;
  for (i = 2; i <= N; i++) Fib[i] = (Fib[i - 1] + Fib[i - 2]) % 1000000000;
  S[0] = 1;
  for (i = 1; i <= N; i++) S[i] = (S[i - 1] + Fib[i]) % 1000000000;
}
long long hesapla(long long s0, long long s1, int n) {
  if (!n) return s0;
  if (n == 1) return s1;
  return (Fib[n - 1] * s1 + Fib[n - 2] * s0) % 1000000000;
}
long long f(int a, int b, int x) {
  long long s(0);
  int i;
  for (i = a; i <= b; i++) s = (s + A[i] * Fib[x++]) % 1000000000;
  return s;
}
void init(int pos, int s, int e) {
  ST[pos].s0 = f(s, e, 0);
  ST[pos].s1 = f(s, e, 1);
  if (s == e) return;
  int m = (s + e) >> 1;
  init(pos << 1, s, m);
  init((pos << 1) + 1, m + 1, e);
}
KD update1(int pos, int s, int e, int a, long long v) {
  if (a < s || a > e) return ST[pos];
  if (s == e) return ST[pos] = make_kd(v, v, 0);
  int m = (s + e) >> 1;
  int k = e - s + 1;
  KD p1 = update1(pos << 1, s, m, a, v);
  KD p2 = update1((pos << 1) + 1, m + 1, e, a, v);
  ST[pos].s0 =
      (p1.s0 + hesapla(p2.s0, p2.s1, m - s + 1) + ST[pos].s * S[k - 1]) %
      1000000000;
  ST[pos].s1 =
      (p1.s1 + hesapla(p2.s0, p2.s1, m - s + 2) + ST[pos].s * (S[k] - 1)) %
      1000000000;
  return ST[pos];
}
KD update2(int pos, int s, int e, int a, int b, long long v) {
  if (a > e || b < s) return ST[pos];
  int k = e - s + 1;
  if (a <= s && e <= b) {
    ST[pos].s = (ST[pos].s + v) % 1000000000;
    ST[pos].s0 = (ST[pos].s0 + v * S[k - 1]) % 1000000000;
    ST[pos].s1 = (ST[pos].s1 + v * (S[k] - 1)) % 1000000000;
    return ST[pos];
  }
  int m = (s + e) >> 1;
  KD p1 = update2(pos << 1, s, m, a, b, v);
  KD p2 = update2((pos << 1) + 1, m + 1, e, a, b, v);
  ST[pos].s0 =
      (p1.s0 + hesapla(p2.s0, p2.s1, m - s + 1) + ST[pos].s * S[k - 1]) %
      1000000000;
  ST[pos].s1 =
      (p1.s1 + hesapla(p2.s0, p2.s1, m - s + 2) + ST[pos].s * (S[k] - 1)) %
      1000000000;
  return ST[pos];
}
KD find(int pos, int s, int e, int a, int b, long long syc) {
  if (a > e || b < s) return make_kd(0, 0, 0);
  int k = e - s + 1;
  if (a <= s && e <= b)
    return make_kd((ST[pos].s0 + syc * S[k - 1]) % 1000000000,
                   (ST[pos].s1 + syc * (S[k] - 1)) % 1000000000, k);
  int m = (s + e) >> 1;
  KD p1 = find(pos << 1, s, m, a, b, (syc + ST[pos].s) % 1000000000);
  KD p2 = find((pos << 1) + 1, m + 1, e, a, b, (syc + ST[pos].s) % 1000000000);
  KD res;
  res.size = p1.size + p2.size;
  res.s0 = (p1.s0 + hesapla(p2.s0, p2.s1, p1.size)) % 1000000000;
  res.s1 = (p1.s1 + hesapla(p2.s0, p2.s1, p1.size + 1)) % 1000000000;
  return res;
}
void solve() {
  int a, b, i, k;
  long long v;
  scanf("%d %d", &N, &M);
  init_Fib();
  for (i = 1; i <= N; i++) scanf("%lld", A + i);
  init(1, 1, N);
  for (i = 1; i <= M; i++) {
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d %lld", &a, &v);
      update1(1, 1, N, a, v);
    } else if (k == 2) {
      scanf("%d %d", &a, &b);
      printf("%lld\n", find(1, 1, N, a, b, 0).s0);
    } else {
      scanf("%d %d %lld", &a, &b, &v);
      update2(1, 1, N, a, b, v);
    }
  }
}
int main() {
  solve();
  return 0;
}

```