#include <bits/stdc++.h>
using namespace std;
constexpr const int maxn = 500000;
constexpr const int bloc = 1024;
int a[maxn + 1], b[bloc][bloc];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int q;
  cin >> q;
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i != bloc; ++i) b[i][x % i] += y;
    } else {
      int res = 0;
      if (x < bloc) {
        res = b[x][y];
      } else {
        for (int i = y; i <= maxn; i += x) res += a[i];
      }
      cout << res << '\n';
    }
  }
}
