#include <bits/stdc++.h>
using namespace std;
struct F {
  long long a[500005];
  long long sum[710][710];
  int Q;
  void init() { cin >> Q; }
  void work() {
    long long ans;
    int op, x, y;
    while (Q--) {
      cin >> op >> x >> y;
      if (op == 1) {
        a[x] += y;
        for (int i = 1; i <= 707; i++) sum[i][x % i] += y;
      } else {
        if (x <= 707)
          cout << sum[x][y] << endl;
        else {
          ans = 0;
          for (int k = y; k <= 500000; k += x) ans += a[k];
          cout << ans << endl;
        }
      }
    }
  }
} sol;
int main() {
  ios::sync_with_stdio(false);
  sol.init();
  sol.work();
  return 0;
}
