#include <bits/stdc++.h>
using namespace std;
long long int pos(long long int n) {
  if (n >= 0) {
    return n;
  }
  return -n;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
long long int arr[500005];
long long int dp[720][720];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int q;
  cin >> q;
  while (q--) {
    long long int x, a, b;
    cin >> x >> a >> b;
    if (x == 1) {
      arr[a] += b;
      for (long long int i = 1; i <= 710; i++) {
        dp[i][a % i] += b;
      }
    } else {
      if (a * a <= 500000) {
        cout << dp[a][b] << "\n";
      } else {
        long long int ans = 0;
        long long int w = b;
        while (w <= 500000) {
          ans += arr[w];
          w += a;
        }
        cout << ans << "\n";
      }
    }
  }
}
