#include <bits/stdc++.h>
using namespace std;
const long long N = 1000000007;
long long q;
long long md[255][255] = {0};
long long a[500005] = {0};
int main() {
  long long op, x, y;
  scanf("%lld", &q);
  while (q--) {
    scanf("%lld %lld %lld", &op, &x, &y);
    if (op == 1) {
      for (long long i = 1; i <= 250; i++) md[i][x % i] += y;
      a[x] += y;
    }
    if (op == 2) {
      long long ans = 0;
      if (x > 250) {
        for (long long i = y; i <= 500000; i += x) ans += a[i];
      } else
        ans = md[x][y];
      printf("%lld\n", ans);
    }
  }
  return 0;
}
