#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll sum[305][305];
ll a[500005];
int main() {
  cin.sync_with_stdio(false), cin.tie(nullptr);
  int q;
  cin >> q;
  while (q--) {
    int op, x, y;
    cin >> op >> x >> y;
    if (op == 1) {
      a[x] += y;
      for (int i = 1; i <= 300; i++) {
        sum[i][x % i] += y;
      }
    } else if (x <= 300) {
      cout << sum[x][y] << "\n";
    } else {
      ll res = 0;
      for (int i = y; i <= 500000; i += x) {
        res += a[i];
      }
      cout << res << "\n";
    }
  }
}
