#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 2e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  int q;
  cin >> q;
  const int maxn = 5e5 + 10;
  vector<int> a(maxn);
  vector<vector<int>> mn(1001, vector<int>(1001));
  while (q--) {
    int type, x, y;
    cin >> type >> x >> y;
    if (type == 1) {
      a[x] += y;
      for (int i = 1; i <= 1000; ++i) {
        mn[i][x % i] += y;
      }
    } else {
      if (x > 1000) {
        int answer = 0;
        int it = y;
        while (it < maxn) {
          answer += a[it];
          it += x;
        }
        cout << answer << '\n';
      } else {
        cout << mn[x][y] << '\n';
      }
    }
  }
  return 0;
}
