#include <bits/stdc++.h>
using namespace std;
long long inf = 4e18, mod = 1e9 + 7;
void solve() {
  int q;
  cin >> q;
  int a[500005] = {0};
  int cnt[1005][1005];
  while (q--) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      for (int i = 1; i <= 1000; i++) {
        cnt[x % i][i] += y;
      }
      a[x] += y;
    } else {
      if (x <= 1000) {
        cout << cnt[y][x] << endl;
      } else {
        int res = 0;
        int val = y;
        while (val <= 500000) {
          res += a[val];
          val += x;
        }
        cout << res << endl;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
}
