#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double PI = acos(-1.);   const int MXN = 200005;   const int MOD = 1000000000;   int a[MXN], n, m;   long long fib[MXN];   long long prefib[MXN];   struct SEG {     int l, r;     long long lazy;     long long g[2];     SEG() {}     SEG(int _l, int _r) { l = _l, r = _r; }   } SGT[MXN << 2];   void create(SEG &T, int t) {     T.lazy = 0;     T.g[0] = T.g[1] = a[t];   }   void fresh(SEG &T, SEG &L, SEG &R) {     int left = L.r - L.l + 1;     T.lazy = 0;     if (left == 1) {       T.g[0] = (L.g[0] + R.g[1]) % MOD;       T.g[1] = (L.g[0] + R.g[0] + R.g[1]) % MOD;       return;     }     T.g[0] =         (L.g[0] + fib[left - 2] * R.g[0] % MOD + fib[left - 1] * R.g[1] % MOD) %         MOD;     T.g[1] =         (L.g[1] + fib[left - 1] * R.g[0] % MOD + fib[left] * R.g[1] % MOD) % MOD;   }   void build(int id, int l, int r) {     SGT[id] = SEG(l, r);     int mid = (l + r) / 2;     if (l != r) {       build(id * 2, l, mid);       build(id * 2 + 1, mid + 1, r);       fresh(SGT[id], SGT[id << 1], SGT[id << 1 | 1]);     } else       create(SGT[id], l);   }   void update(int id, int l, int r, long long w) {     SEG &T = SGT[id];     int mid = (T.l + T.r) / 2;     if (T.l == l && T.r == r) {       T.lazy = (T.lazy + w) % MOD;       T.g[0] = (T.g[0] + w * prefib[T.r - T.l] % MOD) % MOD;       T.g[1] = (T.g[1] + w * (prefib[T.r - T.l + 1] - 1) % MOD) % MOD;       return;     }     if (T.lazy) {       update(id << 1, T.l, mid, T.lazy);       update(id << 1 | 1, mid + 1, T.r, T.lazy);       T.lazy = 0;     }     if (r <= mid)       update(id << 1, l, r, w);     else if (l > mid)       update(id << 1 | 1, l, r, w);     else {       update(id << 1, l, mid, w);       update(id << 1 | 1, mid + 1, r, w);     }     fresh(T, SGT[id << 1], SGT[id << 1 | 1]);   }   long long single(int id, int t) {     SEG &T = SGT[id];     int mid = (T.l + T.r) / 2;     if (T.l == T.r) return T.g[0];     if (t <= mid)       return T.lazy + single(id << 1, t);     else       return T.lazy + single(id << 1 | 1, t);   }   void query(int id, SEG &A) {     SEG &T = SGT[id];     int mid = (T.l + T.r) / 2;     if (A.l == T.l && A.r == T.r) {       A = T;       return;     }     if (T.lazy && T.l != T.r) {       update(id << 1, T.l, mid, T.lazy);       update(id << 1 | 1, mid + 1, T.r, T.lazy);       T.lazy = 0;     }     if (A.r <= mid)       query(id << 1, A);     else if (A.l > mid)       query(id << 1 | 1, A);     else {       SEG L(A.l, mid), R(mid + 1, A.r);       query(id << 1, L);       query(id << 1 | 1, R);       fresh(A, L, R);     }   }   int main() {     int i, j;     fib[0] = 1;     fib[1] = 1;     for (i = 2; i < MXN; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % MOD;     prefib[0] = 1;     for (i = 1; i < MXN; i++) prefib[i] = (prefib[i - 1] + fib[i]) % MOD;     while (~scanf( %d%d , &n, &m)) {       for (i = 1; i <= n; i++) scanf( %d , &a[i]);       build(1, 1, n);       while (m--) {         int q;         scanf( %d , &q);         if (q == 1) {           int x, v;           scanf( %d%d , &x, &v);           long long tp = single(1, x);           update(1, x, x, v - tp);         }         if (q == 2) {           int l, r;           scanf( %d%d , &l, &r);           SEG A(l, r);           query(1, A);           printf( %I64d n , ((A.g[0] % MOD) + MOD) % MOD);         }         if (q == 3) {           int l, r, d;           scanf( %d%d%d , &l, &r, &d);           update(1, l, r, d);         }       }     }     return 0;   }