#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 Mod = 1e9 + 7 ;
const int MX = 1e5 + 5 ;
int evenFreq[MX] , oddFreq[MX] , n , q;
ll power(ll x, ll y)
{
ll Res = 1;
x = x % Mod;
while (y > 0)
{
if (y & 1) Res = (Res * x) % Mod ;
y = y >> 1;
x = (x * x) % Mod;
}
return Res;
}
void update(int index, int value) {
while(index <= n){
evenFreq[index] += (value == 0) ;
oddFreq[index] += (value == 1) ;
index += index & -index ;
}
}
pair < int , int > query(int index) {
int odd = 0 , even = 0;
while(index > 0){
even += evenFreq[index];
odd += oddFreq[index] ;
index -= index & -index ;
}
return {even , odd};
}
void solve()
{
cin >> n >> q ; int a[n] ;
for(auto &x : a) cin >> x ;
for(int i = 0 ; i < n ; i++){
update(i + 1 , a[i] % 2) ;
}
int type , l , r ;
while(q--){
cin >> type >> l >> r ;
pair < int , int > freqOddEvenOfR = query(r) ;
pair < int , int > freqOddEvenOfL = query(l - 1) ;
ll even = freqOddEvenOfR.F - freqOddEvenOfL.F ;
ll odd = freqOddEvenOfR.S - freqOddEvenOfL.S ;
ll Ans = power(2 , even + odd - 1) % Mod ;
if(type == 0) Ans-- ;
cout << Ans << endl ;
}
}
int main()
{
__Heart__
int t ; t = 1; while(t--) solve() ;
}