#include <bits/stdc++.h>
using namespace std;
#define SC scanf
#define PF printf
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sort_a(a) sort(a.begin(),a.end());
#define sort_d(a) sort(a.rbegin(),a.rend());
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rev(s) reverse(s.begin(),s.end())
#define P(ok) cout << (ok ? "YES\n": "NO\n")
#define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll> PII;
const int Mx = 100005 ;
const int Mode = 1000000007 ;
ll n , q , type , l , r , pos , value , BIT[25][Mx];
ll BigMod(ll b,ll p)
{
if(p == 0) return 1;
if( p % 2 == 0)
{
ll ret = BigMod(b, p/2);
return ((ret % Mode ) *(ret % Mode))% Mode;
}
else return ((b % Mode)*(BigMod(b, p-1 ) % Mode))% Mode;
}
void update(ll node , ll i , ll value){
while(i <= n){
BIT[node][i] += value ;
i += i & -i ;
}
}
ll Ask(ll node , ll i) {
ll sum = 0 ;
while(i > 0){
sum += BIT[node][i] ;
i -= i & -i ;
}
return sum ;
}
void solve()
{
cin >> n >> q ; ll A[n + 5] ;
for(int i = 1 ; i <= n ; i++){
cin >> A[i] ;
for(int j = 0 ; j <= 20 ; j++){
update(j, i, ((A[i] >> j) & 1));
}
}
while(q--){
cin >> type ;
if(type == 1) {
cin >> pos >> value ;
for(int i = 0 ; i <= 20 ; i++){
ll bit_before = (A[pos] >> i) & 1;
ll bit_after = ((A[pos] ^ value) >> i) & 1;
update(i, pos, bit_after - bit_before);
}
A[pos] ^= value;
}
else {
cin >> l >> r ;
ll totalBit = 0;
for(int i = 0 ; i <= 20 ; i++){
ll countBit = Ask(i , r) - Ask(i , l - 1) ;
if(countBit > 0) {
totalBit = (totalBit + (1LL << i)) % Mode ;
}
}
// cout <<"Before Shifting " << totalBit << endl ;
ll Ans = (totalBit * BigMod(2 , (r - l))) % Mode;
cout << Ans << "\n" ;
}
}
}
int main()
{
__Heart__
int t ; t = 1 ; while(t--) solve() ;
}