#include <bits/stdc++.h>
using namespace std;
long long a[500005], dp[705][705];
int main() {
  ios::sync_with_stdio(0);
  int n, m, i, j, t, x, y, w;
  cin >> n;
  while (n--) {
    cin >> t >> x >> y;
    if (t == 1) {
      for (i = 1; i <= 700; i++) {
        dp[i][x % i] += y;
      }
      a[x] += y;
    } else {
      if (x <= 700) {
        cout << dp[x][y] << "\n";
      } else {
        long long ans = a[y];
        int temp = (700 / x + (700 % x != 0)) * x + y;
        for (i = temp; i <= 500000; i += x) {
          ans += a[i];
        }
        cout << ans << "\n";
      }
    }
  }
  return 0;
}
