#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int M = 707, N = 5e5 + 5;
long long m[M][M], a[N];
int x, y;
int main(void) {
  int q;
  scanf("%d", &q);
  while (q--) {
    int t;
    scanf("%d %d %d", &t, &x, &y);
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i < M; i++) m[i][x % i] += y;
    } else {
      if (x >= M) {
        long long ans = 0;
        while (y < N) {
          ans += a[y];
          y += x;
        }
        printf("%lld\n", ans);
      } else {
        printf("%lld\n", m[x][y]);
      }
    }
  }
  return 0;
}
