#include <bits/stdc++.h>
using namespace std;
const int sq = 709, maxn = 500 * 1000 + 10;
long long sum[sq][sq], tmp;
int q, t, y, x, a[maxn];
int main() {
  ios::sync_with_stdio(0);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d", &t, &x, &y);
    if (t == 1) {
      for (int j = 1; j < sq; j++) sum[j][x % j] += y;
      a[x] += y;
    } else {
      if (x < sq)
        printf("%lld\n", sum[x][y]);
      else {
        tmp = 0;
        for (int i = y; i <= 500000; i += x) tmp += a[i];
        printf("%lld\n", tmp);
      }
    }
  }
  return 0;
}
