#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const int mod = 998244353;
const int M = 1e3;
long long ans[M + 1][M + 1], arr[N + 10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int cs, x, y;
    cin >> cs >> x >> y;
    if (cs == 1) {
      arr[x] += y;
      for (int j = 1; j <= M; ++j) ans[j][x % j] += y;
    } else {
      if (x <= M)
        cout << ans[x][y] << "\n";
      else {
        long long cr = 0;
        for (int j = y; j <= N; j += x) cr += arr[j];
        cout << cr << "\n";
      }
    }
  }
}
