#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")
using namespace std;
template <typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;
long long int ans[1010][1010];
long long int a[500500];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i <= 800; ++i) {
        ans[i][x % i] += y;
      }
    }
    if (t == 2) {
      if (x > 800) {
        long long int s = 0;
        while (y <= 500000) {
          s += a[y];
          y += x;
        }
        cout << s << endl;
      } else {
        cout << ans[x][y] << endl;
      }
    }
  }
}
