#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  vector<vector<int> > smallTable;
  vector<int> bigTable;
  int breakPoint = 1000;
  smallTable.resize(breakPoint + 1);
  for (int i = 1; i < smallTable.size(); i++) {
    smallTable[i].resize(i);
  }
  bigTable.resize(500000 + 1);
  for (int i = 0; i < q; i++) {
    int queryType;
    cin >> queryType;
    if (queryType == 1) {
      int x, y;
      cin >> x >> y;
      for (int i = 1; i < smallTable.size(); i++) {
        smallTable[i][x % i] += y;
      }
      bigTable[x] += y;
    } else {
      int x, y;
      cin >> x >> y;
      if (x <= breakPoint) {
        cout << smallTable[x][y] << endl;
      } else {
        int answer = 0;
        for (int i = y; i < bigTable.size(); i += x) {
          answer += bigTable[i];
        }
        cout << answer << endl;
      }
    }
  }
}
