#include<bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll ts = 500800;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll md = 785;
ll sum[md + 1][md + 1];
ll main() {
	IOS;
    ll n ; cin >> n ;
    ll a[ts];
    for(ll i = 1; i <= n; i++)  {
    	ll type , x, y ;
    	cin >>type >>  x >> y;
    	if(type == 1) {
    	    a[x] += y;
    	    for(ll i = 1; i <= md; i++ ) {
    	    	sum[i][x % i] += y;
			}
		}
		else {

			if(x > md) {
			    ll ans = 0 ;
			   for(ll i = y; i <= n; i += x) {
			   	ans += a[i];
			   }
			   cout << ans;
			}
			else {
				cout << sum[x][y];
			}
			cout << endl;
		}
	}

}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll ts = 500800;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll md = 708;
int sum[md + 3][md + 3];
signed main() {
	IOS;
    int n ; cin >> n ;
    int a[ts];
    for(int i = 1; i <= n; i++)  {
    	int type , x, y ;
    	cin >>type >>  x >> y;
    	if(type == 1) {
    	    a[x] += y;
    	    for(int i = 1; i < md; i++ ) {
    	    	sum[i][x % i] += y;
			}
		}
		else {

			if(x >= md) {
			    int ans = 0 ;
			   for(int i = y; i <= ts; i += x) {
			   	ans += a[i];
			   }
			   cout << ans;
			}
			else {
				cout << sum[x][y];
			}
			cout << endl;
		}
	}

}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll ts = 500015;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll md = 785;
ll sum[md + 1][md + 1];
signed main() {
	IOS;
    ll n ; cin >> n ;
    ll a[ts];
    for(ll i = 1; i <= n; i++)  {
    	ll type , x, y ;
    	cin >>type >>  x >> y;
    	if(type == 1) {
    	    a[x] += y;
    	    for(ll i = 1; i <= md; i++ ) {
    	    	sum[i][x % i] += y;
			}
		}
		else {

			if(x > md) {
			    ll ans = 0 ;
			   for(ll i = y; i <= n; i += x) {
			   	ans += a[i];
			   }
			   cout << ans;
			}
			else {
				cout << sum[x][y];
			}
			cout << endl;
		}
	}

}


#include<bits/stdc++.h>
using namespace std;
const int N=500002,K=400;

int q,x,y,t,i,s,a[N],S[K][K];

int main(){
	scanf("%d",&q);
	while(q--){
		scanf("%d%d%d",&t,&x,&y);
		if(t==1){
			a[x]+=y;
			for(i=1;i<K;i++)
				S[i][x%i]+=y;
		}
		else{
			if(x<K)
				cout << S[x][y] << endl;
			else{
				s=0;
				for(i=y;i<N;i+=x)
					s+=a[i];
				printf("%d\n",s);
			}
		}
	}
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll ts = 500800;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll md = 785;
ll sum[md + 1][md + 1];
signed main() {
	IOS;
    ll n ; cin >> n ;
    ll a[ts];
    for(ll i = 1; i <= n; i++)  {
    	ll type , x, y ;
    	cin >>type >>  x >> y;
    	if(type == 1) {
    	    a[x] += y;
    	    for(ll i = 1; i <= md; i++ ) {
    	    	sum[i][x % i] += y;
			}
		}
		else {

			if(x > md) {
			    ll ans = 0 ;
			   for(ll i = y; i <= n; i += x) {
			   	ans += a[i];
			   }
			   cout << ans;
			}
			else {
				cout << sum[x][y];
			}
			cout << endl;
		}
	}

}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll ts = 500015;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll md = 785;
ll sum[md + 1][md + 1];
ll main() {
	IOS;
    ll n ; cin >> n ;
    ll a[ts];
    for(ll i = 1; i <= n; i++)  {
    	ll type , x, y ;
    	cin >>type >>  x >> y;
    	if(type == 1) {
    	    a[x] += y;
    	    for(ll i = 1; i <= md; i++ ) {
    	    	sum[i][x % i] += y;
			}
		}
		else {

			if(x > md) {
			    ll ans = 0 ;
			   for(ll i = y; i <= n; i += x) {
			   	ans += a[i];
			   }
			   cout << ans;
			}
			else {
				cout << sum[x][y];
			}
			cout << endl;
		}
	}

}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll ts = 500800;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll md = 400;
int sum[md + 3][md + 3];
signed main() {
	IOS;
    int n ; cin >> n ;
    int a[ts];
    for(int i = 1; i <= n; i++)  {
    	int type , x, y ;
    	cin >>type >>  x >> y;
    	if(type == 1) {
    	    a[x] += y;
    	    for(int i = 1; i < md; i++ ) {
    	    	sum[i][x % i] += y;
			}
		}
		else {

			if(x >= md) {
			    int ans = 0 ;
			   for(int i = y; i < ts; i += x) {
			   	ans += a[i];
			   }
			   cout << ans;
			}
			else {
				cout << sum[x][y];
			}
			cout << endl;
		}
	}

}


#define _CRT_SECURE_NO_WARNINGS

#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const LL L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#define dd c = getchar()
#ifndef dd
#define dd c = gc()
#endif
inline char readalpha() {
	char dd;
	for (; !isalpha(c); dd);
	return c;
}

inline char readchar() {
	char dd;
	for (; c == ' '; dd);
	return c;
}

template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x < 10) {
		putchar(x | 48);
		return;
	}
	write(x / 10);
	putchar((x % 10) | 48);
}

typedef long long LL;

const int maxn = 500005;

vector<LL> ve[maxn];
int aa[maxn];

int main() {
	int n = 500000, Q;
	for (int i = 1; i * i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			ve[i].push_back(0);
		}
	}
	read(Q);
	while (Q--) {
		int a, b, c;
		read(a), read(b), read(c);
		if (a == 1) {
			for (int i = 1; i * i <= n; ++i) {
				ve[i][b % i] += c;
			}
			aa[b] += c;
		} else {
			int ans = 0;
			if ((LL) b * b > n) {
				for (int i = c; i <= n; i += b) {
					ans += aa[i];
				}
			} else {
				ans = ve[b][c];
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const LL L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#define dd c = getchar()
#ifndef dd
#define dd c = gc()
#endif
inline char readalpha() {
	char dd;
	for (; !isalpha(c); dd);
	return c;
}

inline char readchar() {
	char dd;
	for (; c == ' '; dd);
	return c;
}

template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x < 10) {
		putchar(x | 48);
		return;
	}
	write(x / 10);
	putchar((x % 10) | 48);
}

typedef long long LL;

const int maxn = 500005;

vector<int> ve[maxn];
int aa[maxn];

int main() {
	int n = 500000, Q;
//	cout << (int) 500000000 << endl;
	for (int i = 1; i * i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			ve[i].push_back(0);
		}
	}
	read(Q);
	while (Q--) {
		int a, b, c;
		read(a), read(b), read(c);
		if (a == 1) {
			for (int i = 1; i * i <= n; ++i) {
				ve[i][b % i] -= aa[i] - c;
			}
			aa[b] = c;
		} else {
			int ans = 0;
			if (b * b > n) {
				for (int i = c; i <= n; i += b) {
					ans += aa[i];
				}
			} else {
				ans = ve[b][c];
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const LL L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#define dd c = getchar()
#ifndef dd
#define dd c = gc()
#endif
inline char readalpha() {
	char dd;
	for (; !isalpha(c); dd);
	return c;
}

inline char readchar() {
	char dd;
	for (; c == ' '; dd);
	return c;
}

template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x < 10) {
		putchar(x | 48);
		return;
	}
	write(x / 10);
	putchar((x % 10) | 48);
}

typedef long long LL;

const int maxn = 500005;

vector<int> ve[maxn];
int aa[maxn];

int main() {
	int n = 500000, Q;
	for (int i = 1; i * i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			ve[i].push_back(0);
		}
	}
	read(Q);
	while (Q--) {
		int a, b, c;
		read(a), read(b), read(c);
		if (a == 1) {
			for (int i = 1; i * i <= n; ++i) {
				ve[i][b % i] -= aa[i] - c;
			}
			aa[b] = c;
		} else {
			int ans = 0;
			if ((LL) b * b > n) {
				for (int i = c; i <= n; i += b) {
					ans += aa[i];
				}
			} else {
				ans = ve[b][c];
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <map>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

inline char gc() {
	static const LL L = 233333;
	static char sxd[L], *sss = sxd, *ttt = sxd;
	if (sss == ttt) {
		ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
		if (sss == ttt) {
			return EOF;
		}
	}
	return *sss++;
}

#define dd c = getchar()
#ifndef dd
#define dd c = gc()
#endif
inline char readalpha() {
	char dd;
	for (; !isalpha(c); dd);
	return c;
}

inline char readchar() {
	char dd;
	for (; c == ' '; dd);
	return c;
}

template <class T>
inline bool read(T& x) {
	bool flg = false;
	char dd;
	x = 0;
	for (; !isdigit(c); dd) {
		if (c == '-') {
			flg = true;
		} else if(c == EOF) {
			return false;
		}
	}
	for (; isdigit(c); dd) {
		x = (x << 1) + (x << 3) + (c ^ 48);
	}
	if (flg) {
		x = -x;
	}
	return true;
}
#undef dd

template <class T>
inline void write(T x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x < 10) {
		putchar(x | 48);
		return;
	}
	write(x / 10);
	putchar((x % 10) | 48);
}

typedef long long LL;

const int maxn = 500005;

vector<int> ve[maxn];
int aa[maxn];

int main() {
	int n = 500000, Q;
	for (int i = 1; i * i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			ve[i].push_back(0);
		}
	}
	read(Q);
	while (Q--) {
		int a, b, c;
		read(a), read(b), read(c);
		if (a == 1) {
			for (int i = 1; i * i <= n; ++i) {
				ve[i][b % i] -= aa[b] - c;
			}
			aa[b] = c;
		} else {
			int ans = 0;
			if ((LL) b * b > n) {
				for (int i = c; i <= n; i += b) {
					ans += aa[i];
				}
			} else {
				ans = ve[b][c];
			}
			printf("%d\n", ans);
		}
	}
	return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 707;

int q;
int a[N + 1];
int sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      int ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%d\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 150;

int q;
int a[N + 1];
ll sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64D\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 255;

int q;
int a[N + 1];
ll sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64D\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 707;

int q;
ll a[N + 1];
ll sum[BLO][BLO];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64d\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 255;

int q;
int a[N + 1];
int sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      int ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%d\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 707;

int q;
ll a[N + 1];
ll sum[BLO + 5][BLO + 5];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64d\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 128;

int q;
int a[N + 1];
ll sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64D\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 127;

int q;
ll a[N + 1];
ll sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64d\n", ans);
    }
  }
  return 0;
}


/**
 * Author: AcFunction
 * Date:   2019-08-22 21:47:09
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>
#define ll long long
#define db double
#define PII pair <int, int>
#define pb push_back
#define fi first
#define se second

using namespace std;

const int N = 500000;
const int BLO = 128;

int q;
int a[N + 1];
ll sum[BLO][N + 1];

int main() {
  scanf("%d", &q);
  for(int i = 1; i <= q; i++) {
    int op, x, y;
    scanf("%d %d %d", &op, &x, &y);
    if(op == 1) {
      a[x] += y;
      for(int j = 1; j <= BLO; j++) {
        sum[j][x % j] += y;
      }
    }
    else {
      ll ans = 0;
      if(x > BLO) {
        for(int now = y; now <= N; now += x) {
          ans += a[now];
        }
      }
      else ans = sum[x][y];
      printf("%I64d\n", ans);
    }
  }
  return 0;
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const ll N=5e5,inf=1e9,mod=1e9+7;
ll tc,n,m,q,a,b,c,d,i,j,k,l,sum,ans,cnt,mx,mn,flag;
ll ar[N+7],ar2[720][720];
string s;
int32_t main()
{
    faseter_io;
    cin>>n;
    while(n--)
    {
        cin>>a>>b>>c;
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<710; i++)
                ar2[i][b%i]+=c;
            continue;
        }
        if(b*b<=N)ans=ar2[b][c];
        else for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        cout<<ans<<endl;
    }
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const ll N=5e5,inf=1e9,mod=1e9+7;
ll tc,n,m,q,a,b,c,d,i,j,k,l,sum,ans,cnt,mx,mn,flag;
ll ar[N+7],ar2[800][800];
string s;
int32_t main()
{
    cin>>n;
    while(n--)
    {
        cin>>a>>b>>c;
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<750; i++)
                ar2[i][a%i]+=c;
            continue;
        }
        if(b*b<=N)
            for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        else ans=ar2[b][c];
        cout<<ans<<endl;
    }
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const unsigned int N=5e5,inf=1e9,mod=1e9+7;
unsigned int tc,n,m,q,a,b,c,d,i,j,k,l,sum,ans,cnt,mx,mn,flag;
unsigned int ar[N+7],ar2[720][720];

int32_t main()
{
    scanf("%u",&n);
    while(n--)
    {
        scanf("%u%u%u",&a,&b,&c);
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<710; i++)
                ar2[i][b%i]+=c;
            continue;
        }
        if(b*b<=N)ans=ar2[b][c];
        else for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        printf("%u\n",ans);
    }
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const int N=5e5,inf=1e9,mod=1e9+7;
int tc,n,m,q,a,b,c,d,i,j,k,l,sum,ans,cnt,mx,mn,flag;
int ar[N+7],ar2[720][720];

int32_t main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d%d",&a,&b,&c);
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<710; i++)
                ar2[i][b%i]+=c;
            continue;
        }
        if(b*b<=N)ans=ar2[b][c];
        else for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        printf("%d\n",ans);
    }
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const int N=5e5,inf=1e9,mod=1e9+7;
int tc,n,m,q,a,b,c,d,i,j,k,l,sum,cnt,mx,mn,flag;
int ar[N+7],ar2[720][720],ans;

int32_t main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d%d",&a,&b,&c);
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<710; i++)
                ar2[i][b%i]+=c;
            continue;
        }
        if(b<=sqrt(N))ans=ar2[b][c];
        else for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        printf("%d\n",ans);
    }
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const int N=5e5,inf=1e9,mod=1e9+7;
int tc,n,m,q,a,b,c,d,i,j,k,l,sum,cnt,mx,mn,flag;
ll ar[N+7],ar2[720][720],ans;

int32_t main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d%d%d",&a,&b,&c);
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<710; i++)
                ar2[i][b%i]+=c;
            continue;
        }
        if(b*b<=N)ans=ar2[b][c];
        else for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        printf("%lld\n",ans);
    }
}


#include<bits/stdc++.h>
#define faseter_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie();
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
using namespace std;
const ll N=5e5,inf=1e9,mod=1e9+7;
ll tc,n,m,q,a,b,c,d,i,j,k,l,sum,ans,cnt,mx,mn,flag;
ll ar[N+7],ar2[800][800];
string s;
int32_t main()
{
    cin>>n;
    while(n--)
    {
        cin>>a>>b>>c;
        if(a==1)
        {
            ar[b]+=c;
            for(i=1; i<750; i++)
                ar2[i][b%i]+=c;
            continue;
        }
        if(b*b<=N)ans=ar2[b][c];
        else for(i=c,ans=0;i<=N;i+=b)
                ans+=ar[i];
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 1000;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return (pair.first << 7) ^ (pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

char buf[1 << 20], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++)

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 700;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return (pair.first) ^ (pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

char buf[1 << 20], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++)

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

int mods[N][B];

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 400;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return (pair.first) ^ (pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

char buf[1 << 20], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++)

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 700;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return (pair.first) ^ (pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

char buf[1 << 20], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++)

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 800;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return std::hash<int>()(pair.first) ^ std::hash<int>()(pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 500;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return (pair.first << 7) ^ (pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

char buf[1 << 20], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<20, stdin), p1 == p2) ? EOF : *p1++)

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 800;

struct pair_hash {
	std::size_t operator() (const Pair& pair) const {
		return std::hash<int>()(pair.first) ^ std::hash<int>()(pair.second);
	}
};

std::unordered_map<Pair, int, pair_hash> map;
int a[N];

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    std::cin >> t >> x >> y;
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        map[make_pair(i, x % i)] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = map[make_pair(x, y)];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      std::cout << result << "\n";
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  run();
  return 0;
}


#include <bits/stdc++.h>

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 500000 + 1;
const int B = 1000;

int delta[B][B];
int a[N];

int read() {
  char c;
  int flag = 1;
  while (c = getchar(), c < '0' || c > '9') {
    if (c == '-') flag = -1;
  }
  int result = c & 15;
  while (c = getchar(), c >= '0' && c <= '9') {
    result = result * 10 + (c & 15);
  }
  return flag > 0 ? result : -result;
  return result * flag;
}

void write(int x) {
  static char buf[20], len;
  len = 0;
	if (x < 0) {
    putchar('-');
    x = -x;
  }
	for (; x; x /= 10) {
    buf[len ++] = x % 10 + '0';
  }
	if (!len) {
    putchar('0');
  } else {
    while (len) {
      putchar(buf[-- len]);
    }
  }
}

void run(int case_id = 0) {
  int q = read();
  int sum = 0;
  while (q --) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      a[x] += y;
      sum += y;
      for (int i = 2; i < B; ++ i) {
        delta[i][x % i] += y;
      }
    } else {
      int result = 0;
      if (x == 1) {
        result = sum;
      } else if (x < B) {
        result = delta[x][y];
      } else {
        for (int i = y; i < N; i += x) {
          result += a[i];
        }
      }
      write(result);
      putchar('\n');
    }
  }
}

int main() {
  run();
  return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 300;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i < LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x >= LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 750;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i <= LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x > LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 750;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i < LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x > LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 750;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i < LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x >= LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 400;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i < LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x >= LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 500;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i < LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x >= LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define eb emplace_back
#define ii pair<int,int>
#define fi first
#define se second

const int MAXN = 5e5 + 5;
const int LIM = 710;

int q;
ll a[MAXN], b[LIM][LIM];

int main(){
	scanf("%d", &q);
	while(q--){
		int typ, x, y;
		scanf("%d %d %d", &typ, &x, &y);
		if(typ == 1){
			a[x] += y;
			for(int i = 1; i < LIM; ++i){
				b[i][x%i] += y;
			}
		}else{
			ll ans = 0;
			if(x >= LIM){
				for(int i = y; i < MAXN; i += x)
					ans += a[i];
			}else{
				ans = b[x][y];
			}
			printf("%lld\n", ans);
		}
	}
}


#pragma GCC optimize("Ofast,inline,no-stack-protector,fast-math,unroll-loops")
#include<cstdio>
#define ri register int
#define getchar() (p1==p2&&(p2=(p1=ibuf)+fread(ibuf,1,1<<15,stdin),p1==p2)?-1:*p1++)
const int n=500000,t=708;
char ibuf[1<<15],*p1,*p2;
inline int g(){char c,f=0;while((c=getchar())<48||c>57)if(c=='-')f=1;ri a=c&15;while((c=getchar())>=48&&c<=57)a=(a<<3)+(a<<1)+(c&15);return f?~a+1:a;}
int a[500500],sum[998][998];
main(){
	for(ri q=g();q--;){
		ri opt=g(),x=g(),y=g();
		if(opt&1){//O(sqrt(n))
			a[x]+=y;
			for(ri i=1;i<=t;i++)sum[i][x%i]+=y;
		}else{
			if(x>t){//O(sqrt(n))
				ri ans=0;
				for(ri i=y;i<=n;i+=x)ans+=a[i];
				printf("%d\n",ans);
			}else{//O(1)
				printf("%d\n",sum[x][y]);
			}
		}
	}
}


#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define RE register
#define rint RE int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define req(i, l, r) for (rint i = l; i >= r; i--)
#define Each(i) for (rint i = head[u]; i; i = edge[i].nxt)
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second

template <typename T>
void read(T &x) {
  x = 0; char op = getchar(); int F = 1;
  while (!isdigit(op)) {
    if (op == '-') F *= -1; op = getchar();
  }
  while (isdigit(op)) {
    x = (x << 1) + (x << 3) + op - '0'; op = getchar();
  }
  x *= F;
}

template <typename T, typename ...Args>
void read(T &x, Args &...args) {
  read(x); read(args...);
}

const int N = 500005;

long long p[1000][1000];
int a[N], block, n;
int q;

int main() {
  read(q); n = 500000; block = sqrt(n);
  while (q--) {
    int opt, l, r; read(opt, l, r);
    if (opt == 1) {
      a[l] += r;
      for (int i = 1; i <= block; i++)
        p[i][l % i] += r;
    }
    else {
      if (l <= block) {
        printf("%lld\n", p[l][r]);
      }
      else {
        ll ans = 0LL;
        for (int i = (r == 0 ? r + l : r); i <= n; i += l) {
          ans += a[i];
        }
        printf("%lld\n", ans);
      }
    }
  }
  return 0;
}


// luogu-judger-enable-o2
#include <cstdio>
#include <set>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
#include <list>

namespace IO
{
    inline char gc()
    {
        static char s[1<<20|1]={0},*p1=s,*p2=s;
        return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
    }
//	inline char gc() { return getchar(); }
	inline long long read()
	{
		long long ret=0;bool flag=0;char c=gc();
		while ((c<'0')|(c>'9')) flag ^= !(c^'-'),c=gc();
		while ((c>='0')&(c<='9')) ret=(ret<<1)+(ret<<3)+(c^'0'),c=gc();
		return flag?-ret:ret;
 	}
 	char OutputAns[1<<20|1],*OutputCur = OutputAns;
 	inline void output()
 	{
 		OutputCur -= fwrite(OutputAns,1,OutputCur - OutputAns,stdout);
	}
	inline void print(long long ans)
	{
		char s[20]={0};
		if (OutputCur - OutputAns + sprintf(s,"%I64d",ans) >> 20) output();
		OutputCur += sprintf(OutputCur,"%I64d",ans);
	}
	inline void printc(char c)
	{
		if (OutputCur - OutputAns + 1 >> 20) output();
		*(OutputCur++) = c;
	}
}

using IO::read;
using IO::print;
using IO::printc;
using IO::output;

typedef long long int64;

const int M = 5e5 + 11;

int64 Ans[777][777], A[M];

int q, si, n;

int main(void)
{
	q = n = read();
	si = sqrt(M - 11);
	while (q--)
	{
		int opt = read(), x = read(), y = read();
		if (opt == 2)
		{
			if (x <= si) print(Ans[x][y]);
			else
			{
				int64 ans = 0;
				for (int i = y;i < M; i += x) ans += A[i];
				print(ans);
			} printc('\n');
		}
		else
		{
			for (int i = 1;i <= si; ++i)
				Ans[i][x % i] += y;
			A[x] += y;
		}
	} output(); return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=5e5,M=750;
int v[N+10],f[M+10][M+10];
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int opt,a,b;
		scanf("%d%d%d",&opt,&a,&b);
		if(opt==1)
		{
			v[a]+=b;
			for(int i=1;i<=M;i++)
				f[i][a%i]+=b;
		}
		else
		{
			if(a>M)
			{
				int ans=0;
				for(int i=b;i<=N;i+=a)
					ans+=v[i];
				printf("%d\n",ans);
			}
			else printf("%d\n",f[a][b]);
		}
	}
	return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<string>

using namespace std;
const int maxn=500010;
#define LL long long
int main(){
    LL a[maxn],n,t,x,y;
    scanf("%d",&n);
    memset(a,0,sizeof(a));

    //让我来预存一波吧
    LL sum[710][710];
    memset(sum,0,sizeof(sum));
    while(n--){
        cin>>t>>x>>y;
        scanf("%d%d%d",&t,&x,&y);
        if(t==1){
            a[x]+=y;
            for(int i=1;i<=710;i++) sum[i][x%i]+=y;
        }
        else{
            if(x<=710) printf("%lld\n",sum[x][y]);
            else {
                 LL ans=0;
                for(int i=y;i<=500000;i+=x){
                    ans+=a[i];
                }
                printf("%lld\n",ans);
            }
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=5e5,M=750;
int v[N+10],f[M+10][N+10];
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int opt,a,b;
		scanf("%d%d%d",&opt,&a,&b);
		if(opt==1)
		{
			v[a]+=b;
			for(int i=1;i<=M;i++)
				f[i][a%i]+=b;
		}
		else
		{
			if(a>M)
			{
				int ans=0;
				for(int i=b;i<=N;i+=a)
					ans+=v[i];
				printf("%d\n",ans);
			}
			else printf("%d\n",f[a][b]);
		}
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
#define I inline
#define R register
using namespace std;
	int n,Sqrt;
	int a[500010];
	LL sum[1010][1010];
I void work(int x,int y)
{
	a[x]+=y;
	if(x>=Sqrt) return;
	for(R int i=1;i<=Sqrt;i++)
		sum[i][x%i]+=y;
}
I LL solve(int x,int y)
{
	if(x<Sqrt) return sum[x][y];
	LL tot=0;
	for(R int i=y;i<=n;i+=x)
		tot+=a[i];
	return tot;
}
I int read()
{
	int x=0,f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';x=(x<<3)+(x<<1)+(ch^48),ch=getchar());
	return x*f;
}
int main()
{
	int t,x,y;
	n=read();
	Sqrt=sqrt(n);
	for(R int i=1;i<=n;i++)
	{
		t=read(),x=read(),y=read();
		if(t==1) work(x,y); else printf("%lld\n",solve(x,y));
	}
}


#include<bits/stdc++.h>
using namespace std;
#define rint register int
typedef long long LL;
inline int rd(){
   int x=0,f=1;
   char ch=getchar();
   while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
   while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
   return x*f;
}
const int N=500010;
const int L=720;
int n=N-10,m,len,a[N],blo[L][L];
void change(int x,int y) {
	for(rint i=1;i<=len;++i)blo[i][x%i]+=y;
	a[x]+=y;
}
int query(int x,int y) {
	if(x>len) {
		int res=0;
		for(rint i=y;i<=n;i+=x)res+=a[i];
		return res;
	} else return blo[x][y];
}
signed main() {
	m=rd();len=710;
	while(m--) {
		int opt=rd(),x=rd(),y=rd();
		if(opt==1) change(x,y);
		else printf("%d\n",query(x,y));
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 5e5 + 12;
const int M = 1e3 + 12;
int n, k, q, f[M][M], a[N];
int main() {
	scanf("%d", &q);
	n = 5e5; k = sqrt(n);
	while (q--) {
		int opt, x, y;
		scanf("%d%d%d", &opt, &x, &y);
		if (opt == 1) {
			a[x] += y;
			for (int i = 1; i <= k; i++) f[i][x % i] += y;
		} else {
			int ans = 0;
			if (x <= k) ans = f[x][y]; else
			for (int i = y; i <= n; i += x) ans += a[i];
			printf("%d\n", ans);
		}
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
#define I inline
#define R register
using namespace std;
	int n,Sqrt;
	int a[500010];
	LL sum[1010][1010];
I void work(int x,int y)
{
	a[x]+=y;
	for(R int i=1;i<=Sqrt;i++)
		sum[i][x%i]+=y;
}
I LL solve(int x,int y)
{
	if(x<=Sqrt) return sum[x][y];
	LL tot=0;
	for(R int i=y;i<=500000;i+=x)
		tot+=a[i];
	return tot;
}
I int read()
{
	int x=0,f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';x=(x<<3)+(x<<1)+(ch^48),ch=getchar());
	return x*f;
}
int main()
{
	int t,x,y;
	n=read();
	Sqrt=sqrt(500000)+1;
	for(R int i=1;i<=n;i++)
	{
		t=read(),x=read(),y=read();
		if(t==1) work(x,y); else printf("%lld\n",solve(x,y));
	}
}


// luogu-judger-enable-o2
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 500001
#define M 1001
int Q;
int x,y;
int sum[M][M];
int a[N],opt;
int ans;
int main()
{
    scanf("%d",&Q);
    int T=sqrt(N)+1;
    while(Q--)
    {
        scanf("%d%d%d",&opt,&x,&y);
        if(opt==1)
        {
            a[x]+=y;
            for(int i=1;i<=T;i++)
                sum[i][x%i]+=y;
        }
        else
        {
            if(x<=T)
                printf("%d\n",sum[x][y]);
            else
            {
                ans=0;
                for(int i=y;i<=N;i++)
                    ans+=a[i];
                printf("%d\n",ans);
            }
        }
    }
    return 0;
}


#include<cstdio>
using namespace std;
const int maxn=500005;
const int M=500;

int a[maxn],val[M+5][M+5];
int op,x,y,ans;
int main(){
    int q;
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int j=1;j<=M;j++){
                val[j][x%j]+=y;
            }
        }
        else {
            ans=0;
            if(x>M){
                for(int j=y;j<=M;j+=x)ans+=a[i];
            }
            else ans=val[x][y];
            printf("%d\n",ans);
        }
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
	int n,Sqrt;
	int a[500010];
	LL sum[1010][1010];
void work(int x,int y)
{
	if(x>=Sqrt)
	{
		a[x]+=y;
		return;
	}
	for(int i=1;i<=Sqrt;i++)
		sum[i][x%i]+=y;
}
LL solve(int x,int y)
{
	if(x<Sqrt) return sum[x][y];
	LL tot=0;
	for(int i=y;i<=n;i+=x)
		tot+=a[i];
	return tot;
}
int main()
{
	int t,x,y;
	scanf("%d",&n);
	Sqrt=sqrt(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d",&t,&x,&y);
		if(t==1) work(x,y); else printf("%lld\n",solve(x,y));
	}
}


#include <bits/stdc++.h>
using namespace std;

typedef long long lint;

const int MAXN = 5e5+5, Sqrt = 710;
int m; lint A[MAXN], sgm[Sqrt][Sqrt];

int main(){
	scanf( "%d", &m);

	for(int opr; scanf( "%d", &opr) && m; -- m){
		if(opr == 1){
			int x; lint y; scanf( "%d%lld", &x, &y);
			for(int i = 1; i < Sqrt; ++ i) sgm[i][x%i] += y;

			A[x] += y;
		}
		else{
			int x, y; scanf( "%d%d", &x, &y);
			if(x < Sqrt) printf( "%lld\n", sgm[x][y]);
			else {
				lint ans = 0;
				for(int i = 0; i*x+y < MAXN; ++ i) ans += A[i*x+y];
				printf( "%lld\n", ans);
			}
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int T,op,x,y,s[3005][3005],a[500005];
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int i=1;i<(int)sqrt(5e5);i++)
                s[i][x%i]+=y;
        }
        else {
            int ans=0;
            if(x>=(int)sqrt(5e5)){
                for(int i=0;i*x+y<=5e5;i++)
                    ans+=a[i*x+y];
            }
            else ans=s[x][y];
            printf("%d\n",ans);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,nn,a[1000005],f[1005][1005];
int main()
{
	n=500000;
	nn=sqrt(n);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int z,x,y,ans=0;
		scanf("%d%d%d",&z,&x,&y);
		if(z==2)
		{
			if(x>nn) for(int i=y;i<=n;i+=x) ans+=a[i];
			else ans=f[x][y];
			printf("%d\n",ans);
		}
		if(z==1)
		{
			for(int j=1;j<=nn;j++) f[j][x%j]+=y-a[x];
			a[x]=y;
		}
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
#define I inline
#define R register
using namespace std;
	int n,Sqrt;
	int a[500010];
	LL sum[1010][1010];
I void work(int x,int y)
{
	a[x]+=y;
	for(R int i=1;i<=Sqrt;i++)
		sum[i][x%i]+=y;
}
I LL solve(int x,int y)
{
	if(x<=Sqrt) return sum[x][y];
	LL tot=0;
	for(R int i=y;i<=n;i+=x)
		tot+=a[i];
	return tot;
}
I int read()
{
	int x=0,f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';x=(x<<3)+(x<<1)+(ch^48),ch=getchar());
	return x*f;
}
int main()
{
	int t,x,y;
	n=read();
	Sqrt=sqrt(n)+1;
	for(R int i=1;i<=n;i++)
	{
		t=read(),x=read(),y=read();
		if(t==1) work(x,y); else printf("%lld\n",solve(x,y));
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
LL data[maxn];
LL cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=1000;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=1000){
                cout<<cnt[x][y]<<endl;
            }
            else{
                LL ans=0;
                for(int i=y;i<=5e5;i+=x){
                    ans+=data[i];
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
int data[maxn];
int cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=700;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=700){
                cout<<cnt[x][y]<<endl;
            }
            else{
                int ans=0;
                for(int i=y;i<=5e5;i+=x){
                    ans+=data[i];
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
LL data[maxn];
LL cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=1000;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=1000){
                cout<<cnt[x][y]<<endl;
            }
            else{
                LL ans=0;
                for(int i=0;i<=5e5;i+=x){
                    ans+=data[i];
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


 #include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
LL data[maxn];
LL cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=400;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=400){
                cout<<cnt[x][y]<<endl;
            }
            else{
                LL ans=0;
                for(int i=y;i<=5e5;i+=x){
                    ans+=data[i];
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


 #include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
LL data[maxn];
LL cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=700;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=700){
                cout<<cnt[x][y]<<endl;
            }
            else{
                LL ans=0;
                for(int i=y;i<=5e5;i+=x){
                    ans+=data[i];
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
int data[maxn];
LL cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=1000;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=1000){
                cout<<cnt[x][y]<<endl;
            }
            else{
                LL ans=data[y];
                while(x+y<=5e5){
                    ans += data[x+y];
                    x+=x;
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
LL data[maxn];
LL cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=1000;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=1000){
                cout<<cnt[x][y]<<endl;
            }
            else{
                LL ans=data[y];
                while(x+y<=5e5){
                    ans += data[x+y];
                    x+=x;
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    solve();
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int maxn = 5e5+5;
int data[maxn];
int cnt[1001][1001];
void solve(){
    int t;
    cin>>t;
    while(t--){
        int a, x, y;
        cin>>a>>x>>y;
        if(a==1){
            data[x]+=y;
            for(int i=1;i<=700;i++){
                cnt[i][x%i]+=y;
            }
        }else{
            if(x<=700){
                cout<<cnt[x][y]<<endl;
            }
            else{
                int ans=0;
                for(int i=y;i<=5e5;i+=x){
                    ans+=data[i];
                }
                cout<<ans<<endl;
            }
        }
    }
}
int main(){
    cin.tie(nullptr);ios::sync_with_stdio(false);
    solve();
}


#include <cstdio>
#include <cctype>
#include <cmath>
#define int long long

namespace FastIO {
	inline int read() {
		char ch = getchar(); int r = 0, w = 1;
		while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
		while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
		return r * w;
	}
	void _write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) _write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x) {
		_write(x);
		puts("");
	}
}

using namespace FastIO;

const int N = 500010;
const int SIZE = sqrt(N);

int n, m;
int a[N];
int f[SIZE][SIZE];

signed main() {
	m = read();
	int size = SIZE;
	while(m--) {
		int op = read(), x = read(), y = read();
		if(op == 2) {
			if(x <= size) write(f[x][y]);
			else {
				int ans = 0;
				for(register int i = y; i <= N; i += x) {
					ans += a[i];
				}
				write(ans);
			}
		}
		else {
			for(register int i = 1; i <= size; i++) {
				f[i][x % i] += y - a[x];
			}
			a[x] = y;
		}
	}
	return 0;
}


#include <cstdio>
#include <cctype>
#include <cmath>
#define int long long

namespace FastIO {
	inline int read() {
		char ch = getchar(); int r = 0, w = 1;
		while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
		while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
		return r * w;
	}
	void _write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) _write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x) {
		_write(x);
		puts("");
	}
}

using namespace FastIO;

const int N = 500000;

int n, m;
int a[N + 10];
int f[710][710];

signed main() {
	m = read();
	int size = sqrt(N);
	while(m--) {
		int op = read(), x = read(), y = read();
		if(op == 2) {
			if(x <= size) write(f[x][y]);
			else {
				int ans = 0;
				for(register int i = y; i <= N; i += x) {
					ans += a[i];
				}
				write(ans);
			}
		}
		else {
			for(register int i = 1; i <= size; i++) {
				f[i][x % i] += y;
			}
			a[x] += y;
		}
	}
	return 0;
}


#include <cstdio>
#include <cctype>
#include <cmath>
#define int long long

namespace FastIO {
	inline int read() {
		char ch = getchar(); int r = 0, w = 1;
		while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
		while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
		return r * w;
	}
	void _write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) _write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x) {
		_write(x);
		puts("");
	}
}

using namespace FastIO;

const int N = 500000;

int n, m;
int a[N + 10];
int f[710][710];

signed main() {
	m = read();
	int size = sqrt(N);
	while(m--) {
		int op = read(), x = read(), y = read();
		if(op == 2) {
			if(x <= size) write(f[x][y]);
			else {
				int ans = 0;
				for(register int i = y; i <= N; i += x) {
					ans += a[i];
				}
				write(ans);
			}
		}
		else {
			for(register int i = 1; i <= size; i++) {
				f[i][x % i] += y - a[x];
			}
			a[x] = y;
		}
	}
	return 0;
}


#include <cstdio>
#include <cctype>
#include <cmath>
#define int long long

namespace FastIO {
	inline int read() {
		char ch = getchar(); int r = 0, w = 1;
		while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
		while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
		return r * w;
	}
	void _write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) _write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x) {
		_write(x);
		puts("");
	}
}

using namespace FastIO;

const int N = 500010;
const int SIZE = sqrt(N);

int n, m;
int a[N];
int f[SIZE][SIZE];

signed main() {
	m = read();
	int size = sqrt(500000);
	while(m--) {
		int op = read(), x = read(), y = read();
		if(op == 2) {
			if(x <= size) write(f[x][y]);
			else {
				int ans = 0;
				for(register int i = y; i <= n; i += x) {
					ans += a[i];
				}
				write(ans);
			}
		}
		else {
			for(register int i = 1; i <= size; i++) {
				f[i][x % i] += y - a[x];
			}
			a[x] = y;
		}
	}
	return 0;
}


#include <cstdio>
#include <cctype>
#include <cmath>

namespace FastIO {
	inline int read() {
		char ch = getchar(); int r = 0, w = 1;
		while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
		while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
		return r * w;
	}
	void _write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) _write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x) {
		_write(x);
		puts("");
	}
}

using namespace FastIO;

const int N = 500010;
const int SIZE = sqrt(N);

int n, m;
int a[N];
int f[SIZE][SIZE];

int main() {
	m = read();
	int size = SIZE;
	while(m--) {
		int op = read(), x = read(), y = read();
		if(op == 2) {
			if(x <= size) write(f[x][y]);
			else {
				int ans = 0;
				for(register int i = y; i <= N; i += x) {
					ans += a[i];
				}
				write(ans);
			}
		}
		else {
			for(register int i = 1; i <= size; i++) {
				f[i][x % i] += y - a[x];
			}
			a[x] = y;
		}
	}
	return 0;
}


#include <cstdio>
#include <cctype>
#include <cmath>

namespace FastIO {
	inline int read() {
		char ch = getchar(); int r = 0, w = 1;
		while(!isdigit(ch)) {if(ch == '-') w = -1; ch = getchar();}
		while(isdigit(ch)) {r = r * 10 + ch - '0', ch = getchar();}
		return r * w;
	}
	void _write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) _write(x / 10);
		putchar(x % 10 + '0');
	}
	inline void write(int x) {
		_write(x);
		puts("");
	}
}

using namespace FastIO;

const int N = 500010;
const int SIZE = sqrt(N);

int n, m;
int a[N];
int f[SIZE][SIZE];

int main() {
	m = read();
	int size = sqrt(500000);
	while(m--) {
		int op = read(), x = read(), y = read();
		if(op == 2) {
			if(x <= size) write(f[x][y]);
			else {
				int ans = 0;
				for(register int i = y; i <= n; i += x) {
					ans += a[i];
				}
				write(ans);
			}
		}
		else {
			for(register int i = 1; i <= size; i++) {
				f[i][x % i] += y - a[x];
			}
			a[x] = y;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<time.h>
#define ll long long
#define U unsigned
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(x,m,n) for(int x=m;x<=n;x++)
#define All(x)  (x.begin(),x.end())
#define ls rt<<1
#define rs rt<<1|1
#define lson l,m,ls
#define rson m+1,r,rs
#define pb push_back
#define mp make_pair
#define print(x) cout<<(x)
#define pin cout<<'\n'
#define sp cout<<" "
#define println(x) cout<<(x)<<'\n'
#define read(x) cin>>(x)
#define debug cout<<"test"<<'\n'
#define test system("pause");
#define ALL(x) (x.begin(),x.end())
#define siz(x) ((int)x.size())
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int len=sqrt(N);
int n;
ll a[N];
ll val[len+5][len+5];
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int q;
void INIT()
{
    //fill

//    rep(i,1,n)
//    {
//        e[i].clear();
//    }
    mem(a,0);
    mem(val,0);
}
void solve()
{
    INIT();
    while(q--)
    {
        int t;
        int x,y;
        cin>>t>>x>>y;
        assert(x<=500000);
        if(t==1)
        {
            a[x]+=y;

            for(int i=1; i<=len; i++)
            {
                val[i][x%i]+=y;
            }
        }
        else
        {

            if(x<=len)
            {
                println(val[x][y]);
            }
            else
            {
                ll ans=0;
                for(int i=y; i<N; i+=x)
                {
                    ans+=a[i];
                }
                println(ans);
            }

        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>q)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<time.h>
#define ll long long
#define U unsigned
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(x,m,n) for(int x=m;x<=n;x++)
#define All(x)  (x.begin(),x.end())
#define ls rt<<1
#define rs rt<<1|1
#define lson l,m,ls
#define rson m+1,r,rs
#define pb push_back
#define mp make_pair
#define print(x) cout<<(x)
#define pin cout<<'\n'
#define sp cout<<" "
#define println(x) cout<<(x)<<'\n'
#define read(x) cin>>(x)
#define debug cout<<"test"<<'\n'
#define test system("pause");
#define ALL(x) (x.begin(),x.end())
#define siz(x) ((int)x.size())
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int len=sqrt(N);
int n;
int a[N];
ll val[len][len];
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int q;
void INIT()
{
    //fill

//    rep(i,1,n)
//    {
//        e[i].clear();
//    }
    mem(a,0);
    mem(val,0);
}
void solve()
{
    INIT();
    while(q--)
    {
        int t;
        int x,y;
        cin>>t>>x>>y;
        if(t==1)
        {
            a[x]+=y;

            for(int i=1; i<=len; i++)
            {
                val[i][x%i]+=y;
            }

        }
        else
        {
            ll ans=0;

            if(x<=len)
            {
                ans=val[x][y];
            }
            else
            {
                for(int i=y;i<N;i+=x)
                {
                    ans+=a[i];
                }
            }
            println(ans);
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>q)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<time.h>
#define ll long long
#define U unsigned
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(x,m,n) for(int x=m;x<=n;x++)
#define All(x)  (x.begin(),x.end())
#define ls rt<<1
#define rs rt<<1|1
#define lson l,m,ls
#define rson m+1,r,rs
#define pb push_back
#define mp make_pair
#define print(x) cout<<(x)
#define pin cout<<'\n'
#define sp cout<<" "
#define println(x) cout<<(x)<<'\n'
#define read(x) cin>>(x)
#define debug cout<<"test"<<'\n'
#define test system("pause");
#define ALL(x) (x.begin(),x.end())
#define siz(x) ((int)x.size())
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int len=sqrt(N);
int n;
ll a[N];
ll val[len][len];
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int q;
void INIT()
{
    //fill

//    rep(i,1,n)
//    {
//        e[i].clear();
//    }
    mem(a,0);
    mem(val,0);
}
void solve()
{
    INIT();
    while(q--)
    {
        int t;
        int x,y;
        cin>>t>>x>>y;
        assert(x<=500000);
        if(t==1)
        {
            a[x]+=y;

            for(int i=1; i<=len; i++)
            {
                val[i][x%i]+=y;
            }
        }
        else
        {

            if(x<=len)
            {
                println(val[x][y]);
            }
            else
            {
                ll ans=0;
                for(int i=y; i<N; i+=x)
                {
                    ans+=a[i];
                }
                println(ans);
            }

        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>q)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<time.h>
#define ll long long
#define U unsigned
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(x,m,n) for(int x=m;x<=n;x++)
#define All(x)  (x.begin(),x.end())
#define ls rt<<1
#define rs rt<<1|1
#define lson l,m,ls
#define rson m+1,r,rs
#define pb push_back
#define mp make_pair
#define print(x) cout<<(x)
#define pin cout<<'\n'
#define sp cout<<" "
#define println(x) cout<<(x)<<'\n'
#define read(x) cin>>(x)
#define debug cout<<"test"<<'\n'
#define test system("pause");
#define ALL(x) (x.begin(),x.end())
#define siz(x) ((int)x.size())
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int len=sqrt(N);
int n;
ll a[N];
ll val[len][len];
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int q;
void INIT()
{
    //fill

//    rep(i,1,n)
//    {
//        e[i].clear();
//    }
    mem(a,0);
    mem(val,0);
}
void solve()
{
    INIT();
    while(q--)
    {
        int t;
        int x,y;
        cin>>t>>x>>y;
        if(t==1)
        {
            a[x]+=y;

            for(int i=1; i<=len; i++)
            {
                val[i][x%i]+=y;
            }
        }
        else
        {
            ll ans=0;

            if(x<=len)
            {
                ans=val[x][y];
            }
            else
            {
                for(int i=y;i<N;i+=x)
                {
                    ans+=a[i];
                }
            }
            println(ans);
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>q)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<time.h>
#define ll long long
#define U unsigned
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(x,m,n) for(int x=m;x<=n;x++)
#define All(x)  (x.begin(),x.end())
#define ls rt<<1
#define rs rt<<1|1
#define lson l,m,ls
#define rson m+1,r,rs
#define pb push_back
#define mp make_pair
#define print(x) cout<<(x)
#define pin cout<<'\n'
#define sp cout<<" "
#define println(x) cout<<(x)<<'\n'
#define read(x) cin>>(x)
#define debug cout<<"test"<<'\n'
#define test system("pause");
#define ALL(x) (x.begin(),x.end())
#define siz(x) ((int)x.size())
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int len=sqrt(N);
int n;
ll a[N];
ll val[len][len];
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int q;
void INIT()
{
    //fill

//    rep(i,1,n)
//    {
//        e[i].clear();
//    }
    mem(a,0);
    mem(val,0);
}
void solve()
{
    INIT();
    while(q--)
    {
        int t;
        int x,y;
        cin>>t>>x>>y;
        assert(x<=500000);
        if(t==1)
        {
            a[x]+=y;

            for(int i=1; i<len; i++)
            {
                val[i][x%i]+=y;
            }
        }
        else
        {

            if(x<len)
            {
                println(val[x][y]);
            }
            else
            {
                ll ans=0;
                for(int i=y; i<N; i+=x)
                {
                    ans+=a[i];
                }
                println(ans);
            }

        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>q)
    {
        solve();
    }
    return 0;
}


#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char c=getchar();
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
    while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
    return f*x;
}
#define MAXN 500000
#define INF 0x3f3f3f3f
const int Block=700;
LL f[Block+5][Block+5],a[MAXN+5];
int main(){
	int q=read();
	while(q--){
		int opt=read(),x=read(),y=read();
		if(opt==1){
			for(int i=1;i<=Block;i++)
				f[i][x%i]+=y;
			a[x]+=y;
		}
		else{
			if(x<=Block)
				printf("%lld\n",f[x][y]);
			else{
				LL sum=0;
				for(int i=y;i<=MAXN;i+=x)
					sum+=a[i];
				printf("%lld\n",sum);
			}
		}
	}
    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<time.h>
#define ll long long
#define U unsigned
#define mem(x,y) memset(x,y,sizeof(x))
#define rep(x,m,n) for(int x=m;x<=n;x++)
#define All(x)  (x.begin(),x.end())
#define ls rt<<1
#define rs rt<<1|1
#define lson l,m,ls
#define rson m+1,r,rs
#define pb push_back
#define mp make_pair
#define print(x) cout<<(x)
#define pin cout<<'\n'
#define sp cout<<" "
#define println(x) cout<<(x)<<'\n'
#define read(x) cin>>(x)
#define debug cout<<"test"<<'\n'
#define test system("pause");
#define ALL(x) (x.begin(),x.end())
#define siz(x) ((int)x.size())
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf=0x3f3f3f3f;
const int N=5e5+5;
const int len=sqrt(N);
int n;
ll a[N];
ll val[len][len];
int dir[4][2]= {{1,0},{-1,0},{0,1},{0,-1}};
int q;
void INIT()
{
    //fill

//    rep(i,1,n)
//    {
//        e[i].clear();
//    }
    mem(a,0);
    mem(val,0);
}
void solve()
{
    INIT();
    while(q--)
    {
        int t;
        int x,y;
        cin>>t>>x>>y;
        if(t==1)
        {
            a[x]+=y;

            for(int i=1; i<=len; i++)
            {
                val[i][x%i]+=y;
            }
        }
        else
        {

            if(x<=len)
            {
                println(val[x][y]);
            }
            else
            {
                ll ans=0;
                for(int i=y; i<N; i+=x)
                {
                    ans+=a[i];
                }
                println(ans);
            }

        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>q)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const int N = 700;
int q;
int a[500010];
int d[N + 100][N + 100];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    for (int i = 0; i < q; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] += y;
            if (x <= N) {
                for (int j = 1; j <= N; ++j)
                    d[j][x % j] += y;
            }
            continue;
        }
        int ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (int i = y; i <= 500000; i += x)
                ans += a[i];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const ll N = 700;
int q;
int a[500010];
int d[N + 100][N + 100];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    scanf("%d", &q);
    int t, x, y;
    while(q--){
        scanf("%d%d%d", &t, &x, &y);
        if (t == 1) {
            a[x] += y;
            for (int j = 1; j <= N; ++j)
                d[j][x % j] += y;
            continue;
        }
        int ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (int j = y; j <= 500000; j += x)
                ans += a[j];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const ll N = 700;
ll q;
ll a[500010];
ll d[N + 100][N + 100];
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    while(q--){
        ll t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] += y;
            for (ll j = 1; j <= N; ++j)
                d[j][x % j] += y;
            continue;
        }
        ll ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (ll j = y; j <= 500000; j += x)
                ans += a[j];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const int N = 700;
int q;
int a[500010];
int d[N + 100][N + 100];
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    for (int i = 0; i < q; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] += y;
            if (x <= N) {
                for (int j = 1; j <= N; ++j)
                    d[j][x % j] += y;
            }
            continue;
        }
        int ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (int j = y; j <= 500000; j += x)
                ans += a[i];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const int N = 700;
int q;
int a[500001];
int d[N + 1][N + 1];
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    for (int i = 0; i < q; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] = y;
            if (x <= N) {
                for (int j = 1; j <= N; ++j)
                    d[j][x % j] += y;
            }
            continue;
        }
        int ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (int i = y; i <= 500000; i += x)
                ans += a[i];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const int N = 700;
int q;
int a[500010];
int d[N + 1][N + 1];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    for (int i = 0; i < q; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] += y;
            if (x <= N) {
                for (int j = 1; j <= N; ++j)
                    d[j][x % j] += y;
            }
            continue;
        }
        int ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (int i = y; i <= 500000; i += x)
                ans += a[i];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const int N = 700;
int q;
int a[500010];
int d[N + 100][N + 100];
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    for (int i = 0; i < q; ++i){
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] += y;
            if (x <= N) {
                for (int j = 1; j <= N; ++j)
                    d[j][x % j] += y;
            }
            continue;
        }
        int ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (int j = y; j <= 500000; j += x)
                ans += a[j];
        }
        cout << ans << '\n';
    }
return 0;
}


#include<bits/stdc++.h>
#define maxn 100005

using namespace std;
typedef long long ll;
const ll N = 700;
ll q;
ll a[500010];
ll d[N + 100][N + 100];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> q;
    while(q--){
        ll t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            a[x] += y;
            if (x <= N) {
                for (ll j = 1; j <= N; ++j)
                    d[j][x % j] += y;
            }
            continue;
        }
        ll ans = 0;
        if (x <= N) ans = d[x][y];
        else {
            for (ll j = y; j <= 500000; j += x)
                ans += a[j];
        }
        cout << ans << '\n';
    }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef ONLINE_JUDGE
const int maxn = 123;
#else
const int maxn = 5e5+23;
#endif // ONLINE_JUDGE
const int mod = 998244353;
const int sz= 800;
int n,m,b,op,x,y;
int a[maxn];
ll ans[sz+3][sz+3];
int main()
{
    cin >> n;
    while(n--){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int i=1;i<=sz;i++) ans[x%i][i]+=y;
        }
        else{
            if(x<=sz) printf("%lld\n",ans[y][x]);
            else{
                ll ans=0;
                for(int i=y;i<maxn;i+=x) ans+=a[i];
                printf("%lld\n",ans);
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5+23;
const int mod = 998244353;
const int sz= 708;
int n,m,b,op,x,y;
int a[maxn];
ll ans[sz+3][sz+3];
int main()
{
    cin >> n;
    while(n--){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int i=1;i<=sz;i++) ans[x%i][i]+=y;
        }
        else{
            if(x<=sz) printf("%lld\n",ans[y][x]);
            else{
                ll ans=0;
                for(int i=y;i<maxn;i+=x) ans+=a[i];
                printf("%lld\n",ans);
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef ONLINE_JUDGE
const int maxn = 5e5+23;
#else
const int maxn = 123;
#endif // ONLINE_JUDGE
const int mod = 998244353;
const int sz= 800;
int n,m,b,op,x,y;
int a[maxn];
ll ans[sz+3][sz+3];
int main()
{
    cin >> n;
    while(n--){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int i=1;i<=sz;i++) ans[x%i][i]+=y;
        }
        else{
            if(x<=sz) printf("%lld\n",ans[y][x]);
            else{
                ll ans=0;
                for(int i=y;i<maxn;i+=x) ans+=a[i];
                printf("%lld\n",ans);
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5+23;
const int mod = 998244353;
const int sz=708;
int n,m,b,op,x,y;
int a[maxn];
ll ans[sz+3][sz+3];
int main()
{
    cin >> n;
    while(n--){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int i=1;i<=sz;i++) ans[x%i][i]+=y;
        }
        else{
            if(y<=sz) printf("%lld\n",ans[y][x]);
            else{
                ll ans=0;
                for(int i=y;i<maxn;i+=x) ans+=a[i];
                printf("%lld\n",ans);
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5+23;
const int mod = 998244353;
const int sz= 800;
int n,m,b,op,x,y;
int a[maxn];
ll ans[sz+3][sz+3];
int main()
{
    cin >> n;
    while(n--){
        scanf("%d%d%d",&op,&x,&y);
        if(op==1){
            a[x]+=y;
            for(int i=1;i<=sz;i++) ans[x%i][i]+=y;
        }
        else{
            if(x<=sz) printf("%lld\n",ans[y][x]);
            else{
                ll ans=0;
                for(int i=y;i<maxn;i+=x) ans+=a[i];
                printf("%lld\n",ans);
            }
        }
    }
}


#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

#define INF (1e9)
#define N 500000
vector<int> ans;
#define P 750
int result[P+1][P+1];
int main() {
	int p = int(sqrt(N));
	int q;
	cin >> q;
	ans.resize(N+10);
	for (int i = 0; i < q; i++) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		if (t == 1) {
			ans[x] += y;
			for (int i = 1; i <= P; i++) {
				result[i][x%i] += y;
			}
		} else {
			if (x > p) {
				int m = 0;
				while (y <= N) {
					m += ans[y];
					y += x;
				}
				printf("%d\n", m);
			} else {
				printf("%d\n", result[x][y]);
			}
		}
	}
	return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

#define INF (1e9)
#define N 500000
vector<tuple<int, int, int> > qarr;
set<pair<int, int> > ns[N+1];
set<pair<int, int> > s;
set<tuple<int, int, int> > res;
vector<int> ans;
vector<int> resv;
int main() {
	int p = int(sqrt(N));
	int q;
	cin >> q;
	qarr.reserve(q);
	resv.resize(N+1);
	int resvi = 0;
	for (int i = 0; i < q; i++) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		qarr.emplace_back(t, x, y);
		if (t == 1) continue;
		if (x <= p && s.find(make_pair(x, y)) == s.end()) {
			res.insert(make_tuple(x, y, resvi++));
			s.insert(make_pair(x, y));
			int ny = y;
			while (ny <= N) {
				ns[ny].insert(make_pair(x, y));
				ny += x;
			}
		}
	}
	ans.resize(N+1);
	for (int i = 0; i < q; i++) {
		int t, x, y;
		t = get<0>(qarr[i]);
		x = get<1>(qarr[i]);
		y = get<2>(qarr[i]);
		if (t == 1) {
			ans[x] += y;
			for (auto &v: ns[x]) {
				auto it = res.lower_bound(make_tuple(v.first, v.second, 0));
				resv[get<2>(*it)] += y;
			}
		} else {
			if (x <= p) {
				auto it = res.lower_bound(make_tuple(x, y, 0));
				printf("%d\n", resv[get<2>(*it)]);
			} else {
				int m = 0;
				while (y <= N) {
					m += ans[y];
					y += x;
				}
				printf("%d\n", m);
			}
		}
	}
	return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

#define INF (1e9)
#define N 500000
vector<tuple<int, int, int> > qarr;
set<pair<int, int> > ns[N+1];
set<pair<int, int> > s;
set<tuple<int, int, int> > res;
vector<int> ans;
int main() {
	int p = int(sqrt(N));
	int q;
	cin >> q;
	qarr.reserve(q);
	for (int i = 0; i < q; i++) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		qarr.emplace_back(t, x, y);
		if (t == 1) continue;
		if (x <= p && s.find(make_pair(x, y)) == s.end()) {
			res.insert(make_tuple(x, y, 0));
			s.insert(make_pair(x, y));
			int ny = y;
			while (ny <= N) {
				ns[ny].insert(make_pair(x, y));
				ny += x;
			}
		}
	}
	ans.resize(N+1);
	for (int i = 0; i < q; i++) {
		int t, x, y;
		t = get<0>(qarr[i]);
		x = get<1>(qarr[i]);
		y = get<2>(qarr[i]);
		if (t == 1) {
			ans[x] += y;
			for (auto &v: ns[x]) {
				auto it = res.lower_bound(make_tuple(v.first, v.second, -INF));
				int vx = v.first;
				int vy = v.second;
				int vr = get<2>(*it);
				vr += y;
				res.erase(it);
				res.insert(make_tuple(vx, vy, vr));
			}
		} else {
			if (x <= p) {
				auto it = res.lower_bound(make_tuple(x, y, -INF));
				printf("%d\n", get<2>(*it));
			} else {
				int m = 0;
				while (y <= N) {
					m += ans[y];
					y += x;
				}
				printf("%d\n", m);
			}
		}
	}
	return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

#define INF (1e9)
#define N 500000
vector<tuple<int, int, int> > qarr;
vector<pair<int, int> > ns[N+1];
set<tuple<int, int, int> > res;
vector<int> ans;
vector<int> resv;
int main() {
	int p = int(sqrt(N));
	int q;
	cin >> q;
	qarr.reserve(q);
	resv.resize(N+1);
	int resvi = 0;
	for (int i = 0; i < q; i++) {
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		qarr.emplace_back(t, x, y);
		if (t == 1) continue;
		if (x <= p ) {
			auto it = res.lower_bound(make_tuple(x, y, 0));
			if (get<0>(*it) == x && get<1>(*it) == y) continue;
			res.insert(make_tuple(x, y, resvi++));
			int ny = y;
			while (ny <= N) {
				ns[ny].push_back(make_pair(x, y));
				ny += x;
			}
		}
	}
	ans.resize(N+1);
	for (int i = 0; i < q; i++) {
		int t, x, y;
		t = get<0>(qarr[i]);
		x = get<1>(qarr[i]);
		y = get<2>(qarr[i]);
		if (t == 1) {
			ans[x] += y;
			for (auto &v: ns[x]) {
				auto it = res.lower_bound(make_tuple(v.first, v.second, 0));
				resv[get<2>(*it)] += y;
			}
		} else {
			if (x <= p) {
				auto it = res.lower_bound(make_tuple(x, y, 0));
				printf("%d\n", resv[get<2>(*it)]);
			} else {
				int m = 0;
				while (y <= N) {
					m += ans[y];
					y += x;
				}
				printf("%d\n", m);
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> P;

const int N = 1e5 + 10;

char s[N];
int a[N], b[N];
long long cnt[N], cnt1[N];
P ans[N];
long long rec1, rec2;
int n, now;

void printans(){
	printf("%I64d\n", min(rec1, rec2));
	for (int i = 1; i <= now; i++) printf("%d %d\n", ans[i].first, ans[i].second);
	exit(0);
}

void dfs1(int pos, int v){
	if (pos == n){
		printf("-1\n");
		exit(0);
	}
	if (a[pos] < v){
		for ( ; a[pos] < v && a[pos + 1] < 9; ){
			a[pos]++;
			a[pos + 1]++;
			ans[++now] = {pos, 1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
		if (a[pos] < v) dfs1(pos + 1, 9 + a[pos] - v);
		for ( ; a[pos] < v; ){
			a[pos]++;
			a[pos + 1]++;
			ans[++now] = {pos, 1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
	}
	else if (a[pos] > v){
		for ( ; a[pos] > v && a[pos + 1] > 0; ){
			a[pos]--;
			a[pos + 1]--;
			ans[++now] = {pos, -1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
		if (a[pos] > v) dfs1(pos + 1, a[pos] - v);
		for ( ; a[pos] > v; ){
			a[pos]--;
			a[pos + 1]--;
			ans[++now] = {pos, -1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
	}
}

void dfs2(int pos, int v){
	if (pos == 1){
		printf("-1\n");
		exit(0);
	}
	if (a[pos] < v){
		for ( ; a[pos] < v && a[pos - 1] < 9; ){
			a[pos]++;
			a[pos - 1]++;
			ans[++now] = {pos - 1, 1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
		if (a[pos] < v) dfs1(pos - 1, 9 + a[pos] - v);
		for ( ; a[pos] < v; ){
			a[pos]++;
			a[pos - 1]++;
			ans[++now] = {pos - 1, 1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
	}
	else if (a[pos] > v){
		for ( ; a[pos] > v && a[pos - 1] > 0; ){
			a[pos]--;
			a[pos - 1]--;
			ans[++now] = {pos - 1, -1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
		if (a[pos] > v) dfs1(pos - 1, a[pos] - v);
		for ( ; a[pos] > v; ){
			a[pos]--;
			a[pos - 1]--;
			ans[++now] = {pos - 1, -1};
			if (now == min(rec1, min(rec2, 100000LL))) printans();
		}
	}
}

int main(){
	scanf("%d",&n);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++) a[i] = s[i] - '0';
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++) b[i] = s[i] - '0';
	cnt[1] = 0;
	for (int i = 2; i <= n; i++) cnt[i] = b[i - 1] - (a[i - 1] + cnt[i - 1]);
	if (cnt[n] + a[n] != b[n]){
		printf("-1\n");
		return 0;
	}
	rec1 = 0;
	for (int i = 1; i <= n; i++) rec1 += abs(cnt[i]);
	cnt[n] = 0;
	for (int i = n - 1; i; i--) cnt1[i] = b[i + 1] - (a[i + 1] + cnt1[i + 1]);
	rec2 = 0;
	for (int i = 1; i <= n; i++) rec2 += abs(cnt1[i]);
	now = 0;
	if (rec1 <= rec2){
		for (int i = 1; i <= n - 1; i++) dfs1(i, b[i]);
	}
	else{
		for (int i = n; i >= 2; i--) dfs2(i, b[i]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int conv(char a)
{
    return int(a)-48;
}
vector<pair<int,int>> v;
int tab[1000005];
int tab2[1000005];
int tab3[1000005];
int ile;
void rek(int a,int c)
{
    if(c==-1)
    {
        if(tab[a+1]==0)
            rek(a+1,1);
        tab[a]--;
        tab[a+1]--;
        ile++;
        cout<<a<<" "<<-1<<'\n';
    }
    else
    {
        if(tab[a+1]==9)
            rek(a+1,-1);
        tab[a]++;
        tab[a+1]++;
        ile++;
        cout<<a<<" "<<1<<'\n';
    }
    if(ile>1e5)
        return;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int a;
    cin>>a;
    char znak;
    long long licz=0;
    for(int x=1;x<=a;x++)
    {
        cin>>znak;
        tab[x]=conv(znak);
        if(x%2==1)
            licz+=tab[x];
        else
            licz-=tab[x];
        tab3[x]=tab[x];
    }
    for(int x=1;x<=a;x++)
    {
        cin>>znak;
        tab2[x]=conv(znak);
        if(x%2==1)
            licz-=tab2[x];
        else
            licz+=tab2[x];
    }
    if(licz!=0)
    {
        cout<<-1;
        return 0;
    }
    licz=0;
    int pom;
    for(int x=1;x<=a;x++)
    {
        pom=tab[x]-tab2[x];
        tab[x+1]-=pom;
        licz+=abs(pom);
        tab[x]=tab3[x];
    }
    cout<<licz<<'\n';
    for(int x=1;x<=a;x++)
    {
        if(ile>1e5)
            return 0;
        while(tab[x]>tab2[x])
            rek(x,-1);
        while(tab[x]<tab2[x])
            rek(x,1);
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int conv(char a)
{
    return int(a)-48;
}
vector<pair<int,int>> v;
int tab[1000005];
int tab2[1000005];
int tab3[1000005];
int ile;
void rek(int a,int c)
{
    if(c==-1)
    {
        if(tab[a+1]==0)
            rek(a+1,1);
        if(ile>1e5)
            return;
        tab[a]--;
        tab[a+1]--;
        ile++;
        cout<<a<<" "<<-1<<'\n';
    }
    else
    {
        if(tab[a+1]==9)
            rek(a+1,-1);
        if(ile>1e5)
            return;
        tab[a]++;
        tab[a+1]++;
        ile++;
        cout<<a<<" "<<1<<'\n';
    }
    if(ile>1e5)
        return;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int a;
    cin>>a;
    char znak;
    long long licz=0;
    for(int x=1;x<=a;x++)
    {
        cin>>znak;
        tab[x]=conv(znak);
        if(x%2==1)
            licz+=tab[x];
        else
            licz-=tab[x];
        tab3[x]=tab[x];
    }
    for(int x=1;x<=a;x++)
    {
        cin>>znak;
        tab2[x]=conv(znak);
        if(x%2==1)
            licz-=tab2[x];
        else
            licz+=tab2[x];
    }
    if(licz!=0)
    {
        cout<<-1;
        return 0;
    }
    licz=0;
    int pom;
    for(int x=1;x<=a;x++)
    {
        pom=tab[x]-tab2[x];
        tab[x+1]-=pom;
        licz+=abs(pom);
        tab[x]=tab3[x];
    }
    cout<<licz<<'\n';
    for(int x=1;x<=a;x++)
    {
        if(ile>1e5)
            return 0;
        while(tab[x]>tab2[x])
        {
            if(ile>1e5)
                return 0;
            rek(x,-1);
        }

        while(tab[x]<tab2[x])
        {
            if(ile>1e5)
                return 0;
            rek(x,1);
        }

    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int conv(char a)
{
    return int(a)-48;
}
vector<pair<int,int>> v;
int tab[1000005];
int tab2[1000005];
int tab3[1000005];
int ile;
void rek(int a,int c)
{
    if(ile>1e5)
            return;
    if(c==-1)
    {
        if(tab[a+1]==0)
            rek(a+1,1);
        if(ile>1e5)
            return;
        tab[a]--;
        tab[a+1]--;
        ile++;
        cout<<a<<" "<<-1<<'\n';
    }
    else
    {
        if(tab[a+1]==9)
            rek(a+1,-1);
        if(ile>1e5)
            return;
        tab[a]++;
        tab[a+1]++;
        ile++;
        cout<<a<<" "<<1<<'\n';
    }
    if(ile>1e5)
        return;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int a;
    cin>>a;
    char znak;
    long long licz=0;
    for(int x=1;x<=a;x++)
    {
        cin>>znak;
        tab[x]=conv(znak);
        if(x%2==1)
            licz+=tab[x];
        else
            licz-=tab[x];
        tab3[x]=tab[x];
    }
    for(int x=1;x<=a;x++)
    {
        cin>>znak;
        tab2[x]=conv(znak);
        if(x%2==1)
            licz-=tab2[x];
        else
            licz+=tab2[x];
    }
    if(licz!=0)
    {
        cout<<-1;
        return 0;
    }
    licz=0;
    int pom;
    for(int x=1;x<=a;x++)
    {
        pom=tab[x]-tab2[x];
        tab[x+1]-=pom;
        licz+=abs(pom);
        tab[x]=tab3[x];
    }
    cout<<licz<<'\n';
    for(int x=1;x<=a;x++)
    {
        if(ile>1e5)
            return 0;
        while(tab[x]>tab2[x])
        {
            if(ile>1e5)
                return 0;
            rek(x,-1);
        }

        while(tab[x]<tab2[x])
        {
            if(ile>1e5)
                return 0;
            rek(x,1);
        }

    }
	return 0;
}