#include <bits/stdc++.h>
using namespace std;
int re[1010][1010];
int a[510000];
int q;
int main() {
  int op, x, y;
  cin >> q;
  while (q--) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      for (int i = 1; i <= 800; i++) re[i][x % i] += y;
      a[x] += y;
    } else {
      if (x <= 800)
        cout << re[x][y] << endl;
      else {
        int ans = 0;
        for (int i = y; i <= 500000; i += x) ans += a[i];
        cout << ans << endl;
      }
    }
  }
  return ~~(0 ^ 0 ^ 0);
}
