#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class Fun> class y_combinator_result {
Fun fun_;
public:
template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
template<typename a, typename B> ostream& operator<<(ostream &os, const pair<a, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename... Args> ostream& operator<<(ostream& os, const tuple<Args...>& t) { os << '('; apply([&os](const Args&... args) { size_t n = 0; ((os << args << (++n != sizeof...(Args) ? ", " : "")), ...); }, t); return os << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T>ostream& operator<<(ostream& os, queue<T>& _q) { queue<T> q = _q; os << '{'; string sep; while (!q.empty()) { os << sep << q.front(); sep = ", "; q.pop(); } return os << '}';}
template<typename T>ostream& operator<<(ostream& os, stack<T> st) { os << '{'; string sep; while (!st.empty()) { os << sep << st.top(); sep = ", "; st.pop(); } return os << '}';}
template<typename T, typename Container, typename Compare>ostream& operator<<(ostream& os, priority_queue<T, Container, Compare> pq) { os << '{'; string sep; while (!pq.empty()) { os << sep << pq.top(); sep = ", "; pq.pop(); } return os << '}';}
template<size_t n>ostream& operator<<(ostream& os, const bitset<n>& bs) { return os << bs.to_string();}
void debug_out() { cout << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cout << ' ' << H; debug_out(T...); }
#ifdef LOCAL_DEBUG
#define debug(...) cout << "[Line " << __LINE__ << "] (" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
/*
*/
const int MOD = 1e9 + 7;
const int MAXB = 21;
int n, q;
vector<int> a, pow2;
struct BIT {
vector<int> tree;
int size;
void init(int n) {
size = n;
tree.assign(n + 2, 0);
}
void update(int i, int del) {
while (i <= size) {
tree[i] += del;
i += i & -i;
}
}
int query(int i) {
int res = 0;
while (i > 0) {
res += tree[i];
i -= i & -i;
}
return res;
}
int query(int l, int r) {
return query(r) - query(l - 1);
}
};
vector<BIT> bits;
void update(int pos, int x) {
for (int bit = 0; bit < MAXB; bit++) {
int was = (a[pos] >> bit) & 1;
int is = (x >> bit) & 1;
if (was != is) {
bits[bit].update(pos, is - was);
}
}
a[pos] = x;
}
void run_case() {
cin >> n >> q;
a.resize(n + 1);
pow2.resize(n + 1);
pow2[0] = 1;
for (int i = 1; i <= n; i++) {
pow2[i] = (pow2[i - 1] * 2) % MOD;
}
bits.resize(MAXB);
for (int bit = 0; bit < MAXB; bit++) {
bits[bit].init(n);
}
for (int i = 1; i <= n; i++) {
cin >> a[i];
for (int bit = 0; bit < MAXB; bit++) {
if ((a[i] >> bit) & 1) {
bits[bit].update(i, 1);
}
}
}
while (q--) {
int type;
cin >> type;
if (type == 1) {
int pos, x;
cin >> pos >> x;
update(pos, a[pos] ^ x);
} else {
int l, r;
cin >> l >> r;
int res = 0;
for (int bit = 0; bit < MAXB; bit++) {
int cnt = bits[bit].query(l, r);
if (cnt > 0) {
res = (res + (1LL << bit) * pow2[r - l] % MOD) % MOD;
}
}
cout << res << '\n';
}
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin.exceptions(cin.failbit);
int T = 1;
for (int t = 1; t <= T; t++) {
run_case();
}
return 0;
}