#include <bits/stdc++.h>
using namespace std;
const int block = 708;
int sum[block][block];
int a[500001];
int main() {
  int q, i, j, t, x, y;
  scanf("%d", &q);
  for (i = 0; i < block; ++i) {
    for (j = 0; j < block; ++j) {
      sum[i][j] = 0;
    }
  }
  for (i = 1; i <= q; ++i) {
    scanf("%d %d %d", &t, &x, &y);
    if (t == 1) {
      a[x] += y;
      for (j = 1; j < block; ++j) {
        sum[j][x % j] += y;
      }
    }
    if (t == 2) {
      if (x < block)
        printf("%d\n", sum[x][y]);
      else {
        int res = 0;
        for (j = y; j <= 500000; j += x) {
          res += a[j];
        }
        printf("%d\n", res);
      }
    }
  }
}
