#include <bits/stdc++.h>
using namespace std;
const int M = 5e5 + 5;
int q, d[M];
long long save[710][710];
int main() {
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      d[x] += y;
      for (int j = 1; j <= 700; j++) {
        save[j][x % j] += y;
      }
    } else {
      long long ans = 0;
      if (x > 700) {
        for (int i = 0; i <= 500000; i += x) {
          if (i + y > 500000) break;
          ans += d[i + y];
        }
      } else {
        ans = save[x][y];
      }
      printf("%I64d\n", ans);
    }
  }
}
