#include <bits/stdc++.h>
const int MOD = 1000000000;
const int SZ = 250000;
;
struct modular_integer {
  long long x;
  modular_integer(int x = 0) : x(x) { assert(x >= 0); }
  int to_int() const { return x; }
  modular_integer operator+(modular_integer b) const { return (x + b.x) % MOD; }
  modular_integer operator-(modular_integer b) const {
    return ((x - b.x) % MOD + MOD) % MOD;
  }
  modular_integer operator*(modular_integer b) const { return (x * b.x) % MOD; }
  modular_integer& operator+=(modular_integer b) {
    x = (x + b.x) % MOD;
    return (*this);
  }
};
struct node {
  modular_integer rval;
  modular_integer roff;
  int sz;
  node() {
    rval = 0;
    roff = 0;
    sz = 0;
  }
};
modular_integer fib[SZ];
node merge(const node& l, const node& r) {
  if (l.sz == 0) return r;
  if (r.sz == 0) return l;
  node res;
  res.sz = (l.sz + r.sz);
  res.rval = l.rval + r.rval * fib[l.sz] + r.roff * (fib[l.sz + 1] - fib[l.sz]);
  res.roff =
      l.roff + r.rval * fib[l.sz - 1] + r.roff * (fib[l.sz] - fib[l.sz - 1]);
  return res;
}
node tree[4 * SZ];
int x[SZ];
int getds(int n) {
  n--;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return n + 1;
}
int ds;
void setv(int x, int v) {
  x += ds;
  tree[x].sz = 1;
  tree[x].rval = v;
  tree[x].roff = 0;
  x >>= 1;
  while (x) {
    tree[x] = merge(tree[2 * x], tree[2 * x + 1]);
    x >>= 1;
  }
}
int sum(int l, int r) {
  node lres;
  node rres;
  l += ds;
  r += ds;
  while (l <= r) {
    if (l & 1) lres = merge(lres, tree[l++]);
    if (~r & 1) rres = merge(tree[r--], rres);
    l >>= 1;
    r >>= 1;
  }
  return merge(lres, rres).rval.to_int();
}
int main() {
  fib[0] = 1;
  fib[1] = 1;
  for (int i = 2; i < SZ; i++) fib[i] = fib[i - 1] + fib[i - 2];
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  ds = getds(n);
  for (int i = 0; i < n; i++) {
    tree[i + ds].rval = x[i];
    tree[i + ds].roff = 0;
    tree[i + ds].sz = 1;
  }
  for (int i = ds - 1; i > 0; i--) {
    tree[i] = merge(tree[2 * i], tree[2 * i + 1]);
  }
  while (m--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int c, v;
      scanf("%d%d", &c, &v);
      c--;
      setv(c, v);
    } else if (t == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      r--;
      printf("%d\n", sum(l, r));
    }
  }
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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>
const int MOD = 1000000000;
const int SZ = 250000;
;
struct modular_integer {
  long long x;
  modular_integer(int x = 0) : x(x) { assert(x >= 0); }
  int to_int() const { return x; }
  modular_integer operator+(modular_integer b) const { return (x + b.x) % MOD; }
  modular_integer operator-(modular_integer b) const {
    return ((x - b.x) % MOD + MOD) % MOD;
  }
  modular_integer operator*(modular_integer b) const { return (x * b.x) % MOD; }
  modular_integer& operator+=(modular_integer b) {
    x = (x + b.x) % MOD;
    return (*this);
  }
};
struct node {
  modular_integer rval;
  modular_integer roff;
  int sz;
  node() {
    rval = 0;
    roff = 0;
    sz = 0;
  }
};
modular_integer fib[SZ];
node merge(const node& l, const node& r) {
  if (l.sz == 0) return r;
  if (r.sz == 0) return l;
  node res;
  res.sz = (l.sz + r.sz);
  res.rval = l.rval + r.rval * fib[l.sz] + r.roff * (fib[l.sz + 1] - fib[l.sz]);
  res.roff =
      l.roff + r.rval * fib[l.sz - 1] + r.roff * (fib[l.sz] - fib[l.sz - 1]);
  return res;
}
node tree[4 * SZ];
int x[SZ];
int getds(int n) {
  n--;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return n + 1;
}
int ds;
void setv(int x, int v) {
  x += ds;
  tree[x].sz = 1;
  tree[x].rval = v;
  tree[x].roff = 0;
  x >>= 1;
  while (x) {
    tree[x] = merge(tree[2 * x], tree[2 * x + 1]);
    x >>= 1;
  }
}
int sum(int l, int r) {
  node lres;
  node rres;
  l += ds;
  r += ds;
  while (l <= r) {
    if (l & 1) lres = merge(lres, tree[l++]);
    if (~r & 1) rres = merge(tree[r--], rres);
    l >>= 1;
    r >>= 1;
  }
  return merge(lres, rres).rval.to_int();
}
int main() {
  fib[0] = 1;
  fib[1] = 1;
  for (int i = 2; i < SZ; i++) fib[i] = fib[i - 1] + fib[i - 2];
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  ds = getds(n);
  for (int i = 0; i < n; i++) {
    tree[i + ds].rval = x[i];
    tree[i + ds].roff = 0;
    tree[i + ds].sz = 1;
  }
  for (int i = ds - 1; i > 0; i--) {
    tree[i] = merge(tree[2 * i], tree[2 * i + 1]);
  }
  while (m--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int c, v;
      scanf("%d%d", &c, &v);
      c--;
      setv(c, v);
    } else if (t == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      r--;
      printf("%d\n", sum(l, r));
    }
  }
  return 0;
}

```