#include <bits/stdc++.h>
using namespace std;
int f[710][710];
int a[500005];
int type, x, y, q;
int main() {
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &type);
    scanf("%d %d", &x, &y);
    if (type == 1) {
      for (int j = 1; j * j <= 500000; j++) {
        f[j][x % j] += y;
      }
      a[x] += y;
    } else {
      int ans = 0;
      if (x <= 500000 / x) {
        printf("%d\n", f[x][y]);
      } else {
        if (y == 0) y = x;
        for (int i = y; i <= 500000; i += x) ans += a[i];
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}
