#include <bits/stdc++.h>
using namespace std;
struct TNode {
  int left, right;
  int L, R;
  long long s1, s2, sum;
  long long val;
};
TNode tree[1000000];
int treeSize = 0;
int a[300000];
long long f[300000], fs[300000];
;
const long long P = 1000000000;
void push(TNode &node) {
  if (node.R - node.L == 1) {
    node.val = 0;
    return;
  }
  long long val = node.val;
  TNode &left = tree[node.left], &right = tree[node.right];
  left.sum = (left.sum + val * (left.R - left.L)) % P;
  left.val = (left.val + val) % P;
  right.sum = (right.sum + val * (right.R - right.L)) % P;
  right.val = (right.val + val) % P;
  left.s1 = (left.s1 + val * fs[left.R - left.L]) % P;
  left.s2 = (left.s2 + val * (fs[left.R - left.L + 1] - 1)) % P;
  right.s1 = (right.s1 + val * fs[right.R - right.L]) % P;
  right.s2 = (right.s2 + val * (fs[right.R - right.L + 1] - 1)) % P;
  node.val = 0;
}
void relax(TNode &node) {
  if (node.R - node.L == 1) {
    return;
  }
  TNode &left = tree[node.left], &right = tree[node.right];
  node.sum = (left.sum + right.sum) % P;
  node.s1 = (left.s1 + f[left.R - left.L] * right.s1 +
             f[left.R - left.L + 1] * right.s2) %
            P;
  node.s2 = (left.s2 + f[left.R - left.L + 1] * right.s1 +
             f[left.R - left.L + 2] * right.s2) %
            P;
}
void change(int p, int x, int v) {
  TNode &node = tree[p];
  if (node.L > x || node.R <= x) {
    return;
  }
  if (node.R - node.L == 1) {
    node.sum = node.s1 = v;
    return;
  }
  push(node);
  change(node.left, x, v);
  change(node.right, x, v);
  relax(node);
}
void changeInt(int p, int l, int r, int x) {
  TNode &node = tree[p];
  if (node.L >= r || l >= node.R) {
    return;
  }
  if (l <= node.L && node.R <= r) {
    node.val = (node.val + x) % P;
    node.sum = (node.sum + x * (node.R - node.L)) % P;
    node.s1 = (node.s1 + x * fs[node.R - node.L]) % P;
    node.s2 = (node.s2 + x * (fs[node.R - node.L + 1] - 1)) % P;
    return;
  }
  push(node);
  changeInt(node.left, l, r, x);
  changeInt(node.right, l, r, x);
  relax(node);
}
long long fsum(int p, int l, int r) {
  TNode &node = tree[p];
  if (node.L >= r || l >= node.R) {
    return 0;
  }
  if (l <= node.L && node.R <= r) {
    return (f[node.L - l + 2] * node.s1 + f[node.L - l + 3] * node.s2) % P;
  }
  push(node);
  return (fsum(node.left, l, r) + fsum(node.right, l, r)) % P;
}
int buildTree(int L, int R) {
  int p = treeSize++;
  TNode &node = tree[p];
  node.L = L;
  node.R = R;
  if (R - L == 1) {
    node.sum = a[L];
    node.s1 = a[L];
    node.s2 = 0;
    return p;
  }
  int M = (L + R) / 2;
  node.left = buildTree(L, M);
  node.right = buildTree(M, R);
  relax(node);
  return p;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  f[0] = 1;
  f[1] = 0;
  fs[1] = 1;
  fs[2] = 1;
  for (int i = 2; i <= N + 10; ++i) {
    f[i] = (f[i - 1] + f[i - 2]) % P;
    fs[i + 1] = (fs[i] + f[i]) % P;
  }
  buildTree(0, N);
  for (int i = 0; i < M; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x, v;
      scanf("%d%d", &x, &v);
      --x;
      change(0, x, v);
    }
    if (t == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      --l;
      printf("%d\n", (int)fsum(0, l, r));
    }
    if (t == 3) {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      --l;
      changeInt(0, l, r, d);
    }
  }
  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;
struct TNode {
  int left, right;
  int L, R;
  long long s1, s2, sum;
  long long val;
};
TNode tree[1000000];
int treeSize = 0;
int a[300000];
long long f[300000], fs[300000];
;
const long long P = 1000000000;
void push(TNode &node) {
  if (node.R - node.L == 1) {
    node.val = 0;
    return;
  }
  long long val = node.val;
  TNode &left = tree[node.left], &right = tree[node.right];
  left.sum = (left.sum + val * (left.R - left.L)) % P;
  left.val = (left.val + val) % P;
  right.sum = (right.sum + val * (right.R - right.L)) % P;
  right.val = (right.val + val) % P;
  left.s1 = (left.s1 + val * fs[left.R - left.L]) % P;
  left.s2 = (left.s2 + val * (fs[left.R - left.L + 1] - 1)) % P;
  right.s1 = (right.s1 + val * fs[right.R - right.L]) % P;
  right.s2 = (right.s2 + val * (fs[right.R - right.L + 1] - 1)) % P;
  node.val = 0;
}
void relax(TNode &node) {
  if (node.R - node.L == 1) {
    return;
  }
  TNode &left = tree[node.left], &right = tree[node.right];
  node.sum = (left.sum + right.sum) % P;
  node.s1 = (left.s1 + f[left.R - left.L] * right.s1 +
             f[left.R - left.L + 1] * right.s2) %
            P;
  node.s2 = (left.s2 + f[left.R - left.L + 1] * right.s1 +
             f[left.R - left.L + 2] * right.s2) %
            P;
}
void change(int p, int x, int v) {
  TNode &node = tree[p];
  if (node.L > x || node.R <= x) {
    return;
  }
  if (node.R - node.L == 1) {
    node.sum = node.s1 = v;
    return;
  }
  push(node);
  change(node.left, x, v);
  change(node.right, x, v);
  relax(node);
}
void changeInt(int p, int l, int r, int x) {
  TNode &node = tree[p];
  if (node.L >= r || l >= node.R) {
    return;
  }
  if (l <= node.L && node.R <= r) {
    node.val = (node.val + x) % P;
    node.sum = (node.sum + x * (node.R - node.L)) % P;
    node.s1 = (node.s1 + x * fs[node.R - node.L]) % P;
    node.s2 = (node.s2 + x * (fs[node.R - node.L + 1] - 1)) % P;
    return;
  }
  push(node);
  changeInt(node.left, l, r, x);
  changeInt(node.right, l, r, x);
  relax(node);
}
long long fsum(int p, int l, int r) {
  TNode &node = tree[p];
  if (node.L >= r || l >= node.R) {
    return 0;
  }
  if (l <= node.L && node.R <= r) {
    return (f[node.L - l + 2] * node.s1 + f[node.L - l + 3] * node.s2) % P;
  }
  push(node);
  return (fsum(node.left, l, r) + fsum(node.right, l, r)) % P;
}
int buildTree(int L, int R) {
  int p = treeSize++;
  TNode &node = tree[p];
  node.L = L;
  node.R = R;
  if (R - L == 1) {
    node.sum = a[L];
    node.s1 = a[L];
    node.s2 = 0;
    return p;
  }
  int M = (L + R) / 2;
  node.left = buildTree(L, M);
  node.right = buildTree(M, R);
  relax(node);
  return p;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  f[0] = 1;
  f[1] = 0;
  fs[1] = 1;
  fs[2] = 1;
  for (int i = 2; i <= N + 10; ++i) {
    f[i] = (f[i - 1] + f[i - 2]) % P;
    fs[i + 1] = (fs[i] + f[i]) % P;
  }
  buildTree(0, N);
  for (int i = 0; i < M; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x, v;
      scanf("%d%d", &x, &v);
      --x;
      change(0, x, v);
    }
    if (t == 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      --l;
      printf("%d\n", (int)fsum(0, l, r));
    }
    if (t == 3) {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      --l;
      changeInt(0, l, r, d);
    }
  }
  return 0;
}

```