#include <bits/stdc++.h>
using namespace std;
const int max_n = 500010;
const int s = 707;
int a[max_n];
int precount[s][s];
int q;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> q;
  for (int i = 0; i < q; i++) {
    int type, x, y;
    cin >> type >> x >> y;
    if (type == 1) {
      a[x] += y;
      for (int j = 1; j < s; j++) {
        precount[j][x % j] += y;
      }
    } else {
      if (x < s) {
        cout << precount[x][y] << '\n';
      } else {
        int ans = 0;
        for (int j = y; j <= 500000; j += x) {
          ans += a[j];
        }
        cout << ans << '\n';
      }
    }
  }
  return 0;
}
