#include <bits/stdc++.h>
using namespace std;
int main() {
  int Q;
  cin >> Q;
  const int B = 750;
  int A[500001] = {0};
  int S[B + 1][B + 1] = {0};
  while (Q--) {
    int t, x, y;
    scanf("%d %d %d", &t, &x, &y);
    if (t == 1) {
      A[x] += y;
      for (int i = 1; i <= B; i++) S[i][x % i] += y;
    } else {
      int ans = 0;
      if (x <= B) {
        ans = S[x][y];
      } else {
        for (int i = y; i <= 500000; i += x) ans += A[i];
      }
      cout << ans << endl;
    }
  }
  return 0;
}
