#include <bits/stdc++.h>
const int maxn = 200005, mod = 1000000000, maxk = maxn << 2;
int n, m;
int f[maxn], pre[maxn], a[maxn], lc[maxk], rc[maxk], lazy[maxk];
struct node {
  int sum0, sum1;
  inline int get(int k) {
    if (k <= 1) return k == 0 ? sum0 : sum1;
    return (1ll * f[k - 2] * sum0 % mod + 1ll * f[k - 1] * sum1 % mod) % mod;
  }
} t[maxk];
inline node merge(int len, node a, node b) {
  node res;
  res.sum0 = (a.sum0 + b.get(len)) % mod;
  res.sum1 = (a.sum1 + b.get(len + 1)) % mod;
  return res;
}
inline void getlazy(int l, int r, int now, int v) {
  t[now].sum0 = (t[now].sum0 + 1ll * (pre[r - l] + mod) % mod * v % mod) % mod;
  t[now].sum1 =
      (t[now].sum1 + 1ll * (pre[r - l + 1] - pre[0] + mod) % mod * v % mod) %
      mod;
  lazy[now] = (lazy[now] + v) % mod;
}
inline void pushdown(int l, int r, int now) {
  if (lazy[now] == 0) return;
  int mid = (l + r) >> 1;
  getlazy(l, mid, lc[now], lazy[now]), getlazy(mid + 1, r, rc[now], lazy[now]);
  lazy[now] = 0;
}
void build(int l, int r, int now) {
  if (l == r) {
    t[now].sum0 = t[now].sum1 = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  lc[now] = now << 1, rc[now] = now << 1 | 1;
  build(l, mid, lc[now]), build(mid + 1, r, rc[now]);
  t[now] = merge(mid - l + 1, t[lc[now]], t[rc[now]]);
}
void update(int l, int r, int now, int L, int R, int v) {
  if (L <= l && r <= R) {
    getlazy(l, r, now, v);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(l, r, now);
  if (L <= mid) update(l, mid, lc[now], L, R, v);
  if (mid < R) update(mid + 1, r, rc[now], L, R, v);
  t[now] = merge(mid - l + 1, t[lc[now]], t[rc[now]]);
}
node query(int l, int r, int now, int L, int R) {
  if (L <= l && r <= R) return t[now];
  int mid = (l + r) >> 1;
  pushdown(l, r, now);
  if (mid >= R) return query(l, mid, lc[now], L, R);
  if (L > mid) return query(mid + 1, r, rc[now], L, R);
  return merge(mid - (l > L ? l : L) + 1, query(l, mid, lc[now], L, R),
               query(mid + 1, r, rc[now], L, R));
}
int main() {
  scanf("%d%d", &n, &m);
  f[0] = f[1] = pre[0] = 1, pre[1] = 2;
  for (int i = 2; i <= n + 1; i++)
    f[i] = (f[i - 1] + f[i - 2]) % mod, pre[i] = (pre[i - 1] + f[i]) % mod;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    int opt, x, y, d;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) update(1, n, 1, x, x, (y - query(1, n, 1, x, x).sum0) % mod);
    if (opt == 2) printf("%d\n", query(1, n, 1, x, y).sum0);
    if (opt == 3) {
      scanf("%d", &d);
      update(1, n, 1, x, y, d);
    }
  }
  return 0;
}

### Prompt

Please formulate a Cpp solution to 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>
const int maxn = 200005, mod = 1000000000, maxk = maxn << 2;
int n, m;
int f[maxn], pre[maxn], a[maxn], lc[maxk], rc[maxk], lazy[maxk];
struct node {
  int sum0, sum1;
  inline int get(int k) {
    if (k <= 1) return k == 0 ? sum0 : sum1;
    return (1ll * f[k - 2] * sum0 % mod + 1ll * f[k - 1] * sum1 % mod) % mod;
  }
} t[maxk];
inline node merge(int len, node a, node b) {
  node res;
  res.sum0 = (a.sum0 + b.get(len)) % mod;
  res.sum1 = (a.sum1 + b.get(len + 1)) % mod;
  return res;
}
inline void getlazy(int l, int r, int now, int v) {
  t[now].sum0 = (t[now].sum0 + 1ll * (pre[r - l] + mod) % mod * v % mod) % mod;
  t[now].sum1 =
      (t[now].sum1 + 1ll * (pre[r - l + 1] - pre[0] + mod) % mod * v % mod) %
      mod;
  lazy[now] = (lazy[now] + v) % mod;
}
inline void pushdown(int l, int r, int now) {
  if (lazy[now] == 0) return;
  int mid = (l + r) >> 1;
  getlazy(l, mid, lc[now], lazy[now]), getlazy(mid + 1, r, rc[now], lazy[now]);
  lazy[now] = 0;
}
void build(int l, int r, int now) {
  if (l == r) {
    t[now].sum0 = t[now].sum1 = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  lc[now] = now << 1, rc[now] = now << 1 | 1;
  build(l, mid, lc[now]), build(mid + 1, r, rc[now]);
  t[now] = merge(mid - l + 1, t[lc[now]], t[rc[now]]);
}
void update(int l, int r, int now, int L, int R, int v) {
  if (L <= l && r <= R) {
    getlazy(l, r, now, v);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(l, r, now);
  if (L <= mid) update(l, mid, lc[now], L, R, v);
  if (mid < R) update(mid + 1, r, rc[now], L, R, v);
  t[now] = merge(mid - l + 1, t[lc[now]], t[rc[now]]);
}
node query(int l, int r, int now, int L, int R) {
  if (L <= l && r <= R) return t[now];
  int mid = (l + r) >> 1;
  pushdown(l, r, now);
  if (mid >= R) return query(l, mid, lc[now], L, R);
  if (L > mid) return query(mid + 1, r, rc[now], L, R);
  return merge(mid - (l > L ? l : L) + 1, query(l, mid, lc[now], L, R),
               query(mid + 1, r, rc[now], L, R));
}
int main() {
  scanf("%d%d", &n, &m);
  f[0] = f[1] = pre[0] = 1, pre[1] = 2;
  for (int i = 2; i <= n + 1; i++)
    f[i] = (f[i - 1] + f[i - 2]) % mod, pre[i] = (pre[i - 1] + f[i]) % mod;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    int opt, x, y, d;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) update(1, n, 1, x, x, (y - query(1, n, 1, x, x).sum0) % mod);
    if (opt == 2) printf("%d\n", query(1, n, 1, x, y).sum0);
    if (opt == 3) {
      scanf("%d", &d);
      update(1, n, 1, x, y, d);
    }
  }
  return 0;
}

```