#include <bits/stdc++.h>
using namespace std;
int bug = 1;
vector<long long int> arr(500001, 0);
vector<vector<long long int>> sum(740, vector<long long int>(740, 0));
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int q;
  cin >> q;
  while (q--) {
    long long int i;
    long long int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      arr[x] += y;
      for (i = 1; i < 740; i++) {
        sum[i][x % i] += y;
      }
    } else {
      if (x >= 740) {
        long long int ans = 0;
        for (i = y; i < 500001; i += x) {
          ans += arr[i];
        }
        cout << ans << endl;
      } else {
        cout << sum[x][y] << endl;
      }
    }
  }
  return 0;
}
