#include <bits/stdc++.h>
int q, n = 500010 - 10, len, cnt;
long long ans;
int a[500010];
long long val[720][720];
int main() {
  len = sqrt(n);
  cnt = cnt / len + 1;
  scanf("%d", &q);
  int op, x, y;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      a[x] += y;
      for (int i = 1; i < 720; i++) val[i][x % i] += y;
    } else {
      ans = 0;
      if (x < 720)
        ans = val[x][y];
      else {
        for (int i = 0; i * x + y <= n; i++) ans += a[i * x + y];
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}
