#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5, n = 710;
long long ans[n][n] = {}, a[N] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int q;
  cin >> q;
  while (q--) {
    long long t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      for (int i = 1; i < n; i++) ans[i][x % i] += y;
      a[x] += y;
    } else {
      if (x < n)
        cout << ans[x][y] << '\n';
      else {
        long long res = 0;
        int i;
        if (y == 0)
          i = x;
        else
          i = y;
        for (; i < N; i += x) res += a[i];
        cout << res << '\n';
      }
    }
  }
  return 0;
}
