#include <bits/stdc++.h>
using namespace std;
const int maxn = 500001;
const int sq = 800;
int A[maxn];
int B[sq][sq];
int main() {
  int q;
  cin >> q;
  memset(A, 0, sizeof(A));
  ;
  memset(B, 0, sizeof(B));
  ;
  while (q--) {
    int Q, x, y;
    cin >> Q >> x >> y;
    if (Q == 1) {
      A[x] += y;
      for (int i = 1; i < sq; i++) {
        B[i][x % i] += y;
      }
    } else {
      if (x < sq) {
        cout << B[x][y] << '\n';
      } else {
        int ans = 0;
        for (int i = y; i < maxn; i += x) ans += A[i];
        cout << ans << '\n';
      }
    }
  }
  return 0;
}
