// ~~ icebear love attttt ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebearat"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 2e5 + 5;
int n, q;
int a[N], fen[N], power2[N];
void update(int x, int val) {
for(; x <= n; x += x & -x) fen[x] += val;
}
int getSum(int x) {
int ans = 0;
for(; x; x -= x & -x) ans += fen[x];
return ans;
}
int get(int l, int r) {
return getSum(r) - getSum(l - 1);
}
void init(void) {
cin >> n >> q;
FOR(i, 1, n) {
cin >> a[i];
if (a[i] % 2 == 0) update(i, +1);
}
}
void process(void) {
power2[0] = 1;
FOR(i, 1, n) power2[i] = 1LL * power2[i - 1] * 2 % MOD;
int type, l, r;
while(q--) {
cin >> type >> l >> r;
if (type == 1) {
if (a[l] % 2 == 0) update(l, -1);
a[l] = r;
if (a[l] % 2 == 0) update(l, +1);
} else {
int even = get(l, r), odd = (r - l + 1) - even;
int ans = 0;
ans = (ans + (power2[even] - 1 + MOD) % MOD) % MOD;
if (odd > 0) {
ans = (ans + (power2[odd - 1] - 1 + MOD) % MOD) % MOD;
ans = (ans + 1LL * (power2[even] - 1 + MOD) % MOD * (power2[odd - 1] - 1 + MOD) % MOD) % MOD;
}
cout << ans << '\n';
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Ly8gfn4gaWNlYmVhciBsb3ZlIGF0dHR0dCB+fgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGxsOwp0eXBlZGVmIHBhaXI8aW50LCBpbnQ+IGlpOwp0eXBlZGVmIHBhaXI8aW50LCBpaT4gaWlpOwoKdGVtcGxhdGU8Y2xhc3MgVD4KICAgIGJvb2wgbWluaW1pemUoVCAmYSwgY29uc3QgVCAmYikgewogICAgICAgIGlmIChhID4gYikgcmV0dXJuIGEgPSBiLCB0cnVlOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KCnRlbXBsYXRlPGNsYXNzIFQ+CiAgICBib29sIG1heGltaXplKFQgJmEsIGNvbnN0IFQgJmIpIHsKICAgICAgICBpZiAoYSA8IGIpIHJldHVybiBhID0gYiwgdHJ1ZTsKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9CgojZGVmaW5lIEZPUihpLGEsYikgZm9yKGludCBpPShhKTsgaTw9KGIpOyArK2kpCiNkZWZpbmUgRk9SUihpLGEsYikgZm9yKGludCBpPShhKTsgaT49KGIpOyAtLWkpCiNkZWZpbmUgUkVQKGksIG4pIGZvcihpbnQgaT0wOyBpPChuKTsgKytpKQojZGVmaW5lIFJFRChpLCBuKSBmb3IoaW50IGk9KG4pLTE7IGk+PTA7IC0taSkKI2RlZmluZSBNQVNLKGkpICgxTEwgPDwgKGkpKQojZGVmaW5lIEJJVChTLCBpKSAoKChTKSA+PiAoaSkpICYgMSkKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGFsbCh4KSB4LmJlZ2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UgMiA9PSAwKSB1cGRhdGUobCwgKzEpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGludCBldmVuID0gZ2V0KGwsIHIpLCBvZGQgPSAociAtIGwgKyAxKSAtIGV2ZW47CiAgICAgICAgICAgIGludCBhbnMgPSAwOwogICAgICAgICAgICBhbnMgPSAoYW5zICsgKHBvd2VyMltldmVuXSAtIDEgKyBNT0QpICUgTU9EKSAlIE1PRDsKICAgICAgICAgICAgaWYgKG9kZCA+IDApIHsKICAgICAgICAgICAgICAgIGFucyA9IChhbnMgKyAocG93ZXIyW29kZCAtIDFdIC0gMSArIE1PRCkgJSBNT0QpICUgTU9EOwogICAgICAgICAgICAgICAgYW5zID0gKGFucyArIDFMTCAqIChwb3dlcjJbZXZlbl0gLSAxICsgTU9EKSAlIE1PRCAqIChwb3dlcjJbb2RkIC0gMV0gLSAxICsgTU9EKSAlIE1PRCkgJSBNT0Q7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY291dCA8PCBhbnMgPDwgJ1xuJzsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgaWYgKGZvcGVuKHRhc2siLmlucCIsICJyIikpIHsKICAgICAgICBmcmVvcGVuKHRhc2siLmlucCIsICJyIiwgc3RkaW4pOwogICAgICAgIGZyZW9wZW4odGFzayIub3V0IiwgInciLCBzdGRvdXQpOwogICAgfQogICAgaW50IHRjID0gMTsKLy8gICAgY2luID4+IHRjOwogICAgd2hpbGUodGMtLSkgewogICAgICAgIGluaXQoKTsKICAgICAgICBwcm9jZXNzKCk7CiAgICB9CiAgICByZXR1cm4gMDsKfQoK