#include <bits/stdc++.h>
using namespace std;
long long a[500005];
long long ans[710][710];
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int flag, x, y;
    cin >> flag >> x >> y;
    if (flag == 1) {
      a[x] += y;
      for (int i = 1; i <= 700; i++) ans[i][x % i] += y;
    } else if (flag == 2) {
      if (x <= 700)
        cout << ans[x][y] << endl;
      else {
        long long res = 0;
        for (long long i = y; i <= 500000; i += x) res += a[i];
        cout << res << endl;
      }
    }
  }
  return 0;
}
