#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
long long cnt[710][710];
int a[500100];
int main() {
  int n;
  scanf("%d", &n);
  for (int ii = 0; ii < n; ++ii) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i <= 700; ++i) {
        cnt[i][x % i] += y;
      }
    } else {
      long long ans = 0;
      if (x > 700) {
        for (int i = y % x; i <= 500000; i += x) {
          ans += a[i];
        }
      } else {
        ans = cnt[x][y % x];
      }
      printf("%I64lld\n", ans);
    }
  }
  return 0;
}
