#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int n = 5e5, bs = 800;
ll a[n + 1], ans[bs + 20][bs + 20];
void add(int x, ll y) {
  a[x] += y;
  for (int i = 1; i <= bs; i++) {
    ans[i][x % i] += y;
  }
}
ll sum(int x, int y) {
  if (x <= bs) return ans[x][y];
  ll ans = 0;
  for (int i = y; i <= n; i += x) ans += a[i];
  return ans;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int op;
    ll x, y;
    scanf("%d%lld%lld", &op, &x, &y);
    if (op == 1)
      add(x, y);
    else
      printf("%lld\n", sum(x, y));
  }
}
