#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 5e5 + 1, mid = 700;
long long temp[mid + 10][mid + 10];
long long a[maxn + 10];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  while (n--) {
    long long t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      a[x] += y;
      for (long long i = 1; i <= mid; ++i) {
        temp[i][x % i] += y;
      }
    } else if (t == 2) {
      long long ans = 0;
      if (x > mid) {
        long long curr = y;
        while (curr < maxn) {
          ans += a[curr];
          curr += x;
        }
      } else {
        ans += temp[x][y];
      }
      cout << ans << '\n';
      ;
    }
  }
  return 0;
}
