#pragmaGCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+10;
struct BIT
{
long long siz;
vector<long long> c;
BIT(long long n):siz(n),c(n+10){}
long long lowbit(long long x)
{
return x&(-x);
}
void add(long long x,long long v)
{
for(long long i=x;i<=siz;i+=lowbit(i))
c[i]+=v;
}
long long sum(long long l,long long r)
{
if(l>r)return 0;
long long sum=0;
for(long long i=r;i>=1;i-=lowbit(i))
sum+=c[i];
for(long long i=l-1;i>=1;i-=lowbit(i))
sum-=c[i];
return sum;
}
};
long long F(long long x)
{
int p=0;
while(!((x>>p)&1 and !((x>>p+1)&1)))p++;
long long res=(1ll<<p+1);
for(int i=p+2;i<63;i++)
if((x>>i)&1)res|=(1ll<<i);
return res;
}
struct Operation
{
int type;
long long x,v,l,r;
}op[M];
int main()
{
ios::sync_with_stdio(false);
long long n,m;
vector<long long> number={0,(long long)(1e18+1)};
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>op[i].type;
if(op[i].type==1)
{
cin>>op[i].x>>op[i].v;
long long x=op[i].x;
while(x<=n)
{
number.push_back(x);
x=F(x);
}
}
else cin>>op[i].l>>op[i].r;
}
sort(number.begin(),number.end());
number.resize(unique(number.begin(),number.end())-number.begin());
BIT seq(number.size());
auto getId=[&number](long long x)
{
return lower_bound(number.begin(),number.end(),x)-number.begin();
};
for(int i=1;i<=m;i++)
{
if(op[i].type==1)
{
long long x=op[i].x;
while(x<=n)
{
seq.add(getId(x),op[i].v);
x=F(x);
}
}
else
{
long long ql=*lower_bound(number.begin(),number.end(),op[i].l);
long long qr=*prev(upper_bound(number.begin(),number.end(),op[i].r));
cout<<seq.sum(getId(ql),getId(qr))<<endl;
}
}
return 0;
}