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