#include <bits/stdc++.h>
using namespace std;
const int N = 600;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int RANGE = 500000 + 10;
  vector<vector<long long>> arr(N, vector<long long>(N, 0));
  vector<int> state(RANGE, 0);
  int q;
  cin >> q;
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      for (int s = 1; s < N; s++) {
        arr[s][x % s] += y;
      }
      state[x] += y;
    } else {
      if (x >= N) {
        long long sum = 0;
        for (int i = y; i < RANGE; i += x) {
          sum += state[i];
        }
        cout << sum << '\n';
      } else {
        cout << arr[x][y] << '\n';
      }
    }
  }
  return (0);
}
