include[HTML_REMOVED]
using namespace std;
int n,m,b[1030][1030],x,y,k,xI,xII,yI,yII;
void zhengli(int xx,int yy)
{
for(int i=xx;i<=n;i)
{
for(int j=yy;j<=n;j)
{
b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
}
}
return;
}
int chaxun(int xI,int yI,int xII,int yII)
{
return b[xII][yII]-b[xII][yI]-b[xI][yII]+b[xI][yI];
}
int main(){
scanf(“%d”,&n);
while(m!=3)
{
scanf(“%d”,&m);
if(m==1)
{
scanf(“%d %d %d”,&x,&y,&k);
b[x+1][y+1]+=k;
zhengli(x+1,y+1);
}
else if(m==2)
{
scanf(“%d %d %d %d”,&xI,&yI,&xII,&yII);
printf(“%d\n”,chaxun(xI+1,yI+1,xII+1,yII+1));
}
}
return 0;
}