#include <bits/stdc++.h>
int sum[710][710], a[500001];
int main() {
  int q, i, op, x, y;
  scanf("%d", &q);
  while (q--) {
    scanf("%d %d %d", &op, &x, &y);
    if (op == 1) {
      a[x] += y;
      for (i = 1; i < 710; ++i) {
        sum[i][x % i] += y;
      }
    } else {
      if (x < 710) {
        printf("%d\n", sum[x][y]);
      } else {
        int prin = 0;
        for (i = 0; i * x + y <= 500000; ++i) {
          prin += a[i * x + y];
        }
        printf("%d\n", prin);
      }
    }
  }
  return 0;
}
