#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main()
{
int n, q;
int ZanCun[5];
vector<vector<int> > Cab;
scanf("%d %d", &n, &q);
#if 0
printf("\n%d %d\n", n, q);
#endif
for(int i = 1; i <= q; i++)
{
memset(ZanCun, 0, 5);
int a;
scanf("%d", &a);
if(a == 1)
{
for(int j = 1; j <= 3; j++)
scanf("%d", &ZanCun[j]);
if(ZanCun[3] != 0)
Cab[ZanCun[1]][ZanCun[2]] += ZanCun[3];
else
Cab[ZanCun[1]][ZanCun[2]] = 0;
}
else if(a == 2)
{
for(int j = 1; j <= 2; j++)
scanf("%d", &ZanCun[j]);
printf("%d\n", Cab[ZanCun[1]][ZanCun[2]]);
}
}
return 0;
}