\#include <bits/stdc++.h>
using namespace std;
#define S cerr << "SYT AK IOI" <<endl;
#define M cerr << "MKF AK IOI" <<endl;
#define CONNECT_BASE(x,y) x##y
#define CONNECT(x,y) CONNECT_BASE(x,y)
#define DEBUG_BASE(x) cerr<<#x<<'='<<x<<' '
#define DEB_1(x) DEBUG_BASE(x)
#define DEB_2(x,y) DEB_1(x),DEB_1(y)
#define DEB_3(x,y,z) DEB_1(x),DEB_2(y,z)
#define DEB_4(x,y,z,w) DEB_1(x),DEB_3(y,z,w)
#define DEB_5(a,b,c,d,e) DEB_1(a),DEB_4(b,c,d,e)
#define DEB_6(a,b,c,d,e,f) DEB_1(a),DEB_5(b,c,d,e,f)
#define COUNT_BASE(_1,_2,_3,_4,_5,_6,x,...) x
#define COUNT(...) COUNT_BASE(__VA_ARGS__,6,5,4,3,2,1,0)
#define D(...) std::cerr << "[In Line " << __LINE__ << "]: ",CONNECT(DEB_,COUNT(__VA_ARGS__))(__VA_ARGS__) , cerr << '\n'
using ll=long long;
using lll=__int128;
using pii=pair<int,int>;
using uint=unsigned int;
using ull=unsigned long long;
#define pb(x) push_back(x)
#define F(i,a,b) for(int i=(a),i##end=(b);i<=(i##end);++i)
#define UF(i,a,b) for(int i=(a),i##end=(b);i>=(i##end);--i)
int n,m;
const int N=2e5+5;
uint a[N];
uint mul[1145][21];
uint tag[1145];
const int mod=1<<20;
int len=314;
namespace BLK{
inline int bl(int x){
return (x-1)/len+1;
}
inline int L(int id){
return len*(id-1)+1;
}
inline int R(int id){
return min(n,len*id);
}
inline void rebuild(int id){
F(i,1,20)mul[id][i]=0;
mul[id][1]=1;
F(i,L(id),R(id)){
UF(j,20,1)mul[id][j]=mul[id][j]*a[i]+mul[id][j-1];
}
}
inline void build(){
F(i,1,n)if(bl(i)!=bl(i-1))rebuild(bl(i));
}
inline void push_down(int id){
if(!tag[id])return;
F(i,L(id),R(id))a[i]+=tag[id];
tag[id]=0;
rebuild(id);
}
inline void add(int l,int r,uint k){
if(bl(l)==bl(r)){
push_down(bl(l));
F(i,l,r)a[i]+=k;
rebuild(bl(l));
return;
}
push_down(bl(l));
F(i,l,R(bl(l)))a[i]+=k;
rebuild(bl(l));
push_down(bl(r));
F(i,L(bl(r)),r)a[i]+=k;
rebuild(bl(r));
F(i,bl(l)+1,bl(r)-1)tag[i]+=k;
}
inline uint query(int l,int r){
uint rt=1;
if(bl(l)==bl(r)){
push_down(bl(l));
F(i,l,r)rt*=a[i];
return rt;
}
push_down(bl(l));
F(i,l,R(bl(l)))rt*=a[i];
rebuild(bl(l));
push_down(bl(r));
F(i,L(bl(r)),r)rt*=a[i];
F(i,bl(l)+1,bl(r)-1){
uint tmp=1;
uint ml=0,cnt=1;
while(tmp%mod){
ml=ml+tmp*mul[i][cnt];
tmp*=tag[i];
++cnt;
}
rt*=ml;
}
return rt;
}
}
using namespace BLK;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin>>n>>m;
F(i,1,n)cin>>a[i];
build();
F(i,1,m){
int op,l,r;
cin>>op>>l>>r;
if(op==1){
uint k;
cin>>k;
add(l,r,k);
}
else {
cout<<query(l,r)%mod<<'\n';
}
}
return 0;
}