#include <bits/stdc++.h>
using namespace std;
int TAB[500000 + 5];
int ask[500000 + 5][4];
int small[800][800];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) cin >> ask[i][0] >> ask[i][1] >> ask[i][2];
  for (int i = 1; i <= q; i++) {
    if (ask[i][0] == 1) {
      TAB[ask[i][1]] += ask[i][2];
      for (int j = 1; j <= 700; j++) small[j][ask[i][1] % j] += ask[i][2];
    } else {
      if (ask[i][1] >= 700) {
        int tmp = 0;
        for (int j = ask[i][2]; j <= 500000; j += ask[i][1]) tmp += TAB[j];
        cout << tmp << '\n';
      } else
        cout << small[ask[i][1]][ask[i][2]] << '\n';
    }
  }
}
