#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int K = 708;
long long f[K][K];
long long a[N];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    static int type;
    scanf("%d", &type);
    if (type == 1) {
      static int i, delt;
      scanf("%d%d", &i, &delt);
      a[i] += delt;
      for (int x = 1; x < K; ++x) f[x][i % x] += delt;
    } else {
      static int x, y;
      scanf("%d%d", &x, &y);
      if (x < K)
        printf("%lld\n", f[x][y]);
      else {
        long long res = 0;
        for (int i = y; i < N; i += x) res += a[i];
        printf("%lld\n", res);
      }
    }
  }
}
