#include <bits/stdc++.h>
using namespace std;
int q;
long long sum[800][800];
long long a[500001];
int main() {
  cin >> q;
  while (q--) {
    int t;
    int x;
    long long y;
    cin >> t >> x >> y;
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i < 800; i++) sum[i][x % i] += y;
    } else {
      if (x >= 800) {
        long long kq = 0;
        for (int i = y; i <= 500000; i += x) kq += a[i];
        cout << kq << "\n";
      } else
        cout << sum[x][y] << "\n";
    }
  }
  return 0;
}
