#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <fstream>
#include <cassert>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define sz(a) int((a).size())
#define rep(i, s, n) for(int i = s; i <= (n); ++i)
#define rev(i, n, s) for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;
ll po(ll x, ll y) {
if (y == 0) return 1;
ll ret = po(x, y / 2);
ret = (ret * ret) % mod;
if (y % 2) {
ret = (ret * x) % mod;
}
return ret;
}
ll inv(ll x) {
return po(x, mod - 2);
}
ll f(ll n) {
ll res = po(7, n);
ll y = (6 * n-1) % mod;
res = (res*y) % mod;
res = ((res + 1) * 7) % mod;
res = (res*inv(36)) % mod;
if (res < 0) res += mod;
return res;
}
ll a[N];
ll read(int x) {
ll sum = 0;
while (x > 0) {
sum += a[x];
if (sum >= mod) sum -= mod;
x -= (x&-x);
}
return sum;
}
void upd(int x, int v) {
while (x < N) {
a[x] += v;
if (a[x] >= mod) a[x] -= mod;
if (a[x] < 0) a[x] += mod;
x += (x&-x);
}
}
int b[N];
int main() {
#ifdef loc
if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
assert(0);
}
freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
boost;
int n, q;
cin >> n >> q;
rep(i, 1, n) {
int x;
cin >> x;
upd(i, f(x));
b[i] = x;
}
while (q-- > 0) {
int ty;
cin >> ty;
if (ty == 1) {
int x, v;
cin >> x >> v;
upd(x, -f(b[x]));
b[x] = v;
upd(x, f(v));
}
else {
int l, r, s;
cin >> l >>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G1haW4oKSB7CiNpZmRlZiBsb2MKICBpZighZnJlb3Blbigoc3RyaW5nKEZPTERFUikgKyAiaW5wLnR4dCIpLmNfc3RyKCksICJyIiwgc3RkaW4pKSB7CiAgICBhc3NlcnQoMCk7CiAgfQogIGZyZW9wZW4oKHN0cmluZyhGT0xERVIpICsgIm91dC50eHQiKS5jX3N0cigpLCAidyIsIHN0ZG91dCk7CiNlbmRpZgogIGJvb3N0OwogIGludCBuLCBxOwogIGNpbiA+PiBuID4+IHE7CiAgcmVwKGksIDEsIG4pIHsKICAgIGludCB4OwogICAgY2luID4+IHg7CiAgICB1cGQoaSwgZih4KSk7CiAgICBiW2ldID0geDsKICB9CiAgd2hpbGUgKHEtLSA+IDApIHsKICAgIGludCB0eTsKICAgIGNpbiA+PiB0eTsKICAgIGlmICh0eSA9PSAxKSB7CiAgICAgIGludCB4LCB2OwogICAgICBjaW4gPj4geCA+PiB2OwogICAgICB1cGQoeCwgLWYoYlt4XSkpOwogICAgICBiW3hdID0gdjsKICAgICAgdXBkKHgsIGYodikpOwogICAgfQogICAgZWxzZSB7CiAgICAgIGludCBsLCByLCBzOwogICAgICBjaW4gPj4gbCA+PiByID4+IHM7CiAgICAgIGludCBhbnMgPSByZWFkKHIpIC0gcmVhZChsIC0gMSk7CiAgICAgIGlmIChhbnMgPCAwKSBhbnMgKz0gbW9kOwogICAgICBhbnMgPSAoYW5zICsgcyoxTEwqKHIgLSBsICsgMSkpICUgbW9kOwogICAgICBjb3V0IDw8IGFucyA8PCAnXG4nOwogICAgfQogIH0KICByZXR1cm4gMDsKfQ==