#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, k, i, j, x, y, ans, mode;
  cin >> q;
  k = 750;
  vector<int> s(500000 + 10, 0);
  vector<vector<int> > l;
  l.resize(k + 5);
  for (i = 1; i < k + 5; i++) {
    l[i].resize(i + 5);
    for (j = 0; j < i + 5; j++) l[i][j] = 0;
  }
  for (i = 0; i < q; i++) {
    cin >> mode >> x >> y;
    if (mode == 1) {
      s[x] += y;
      for (j = 1; j < k; j++) {
        l[j][x % j] += y;
      }
    } else {
      if (x < k) {
        cout << l[x][y] << '\n';
      } else {
        ans = 0;
        for (j = y; j <= 500000; j += x) {
          ans += s[j];
        }
        cout << ans << '\n';
      }
    }
  }
  return 0;
}
