#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 500005;
const int k = 700;
ll in[MAXN], table[k][k];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int q, op, x, y;
  while (cin >> q) {
    while (q--) {
      cin >> op >> x >> y;
      if (op == 1) {
        in[x] += y;
        for (int i = 1; i < 700; ++i) {
          table[i][x % i] += y;
        }
      } else {
        ll res = 0;
        if (x >= k)
          for (int i = y; i <= 500000; i += x) res += in[i];
        else
          res = table[x][y];
        cout << res << '\n';
      }
    }
  }
  return 0;
}
