#include <bits/stdc++.h>
using namespace std;
int q;
int v[505505];
long long int s[500][500];
int main() {
  int ma = 0, mi = 505505;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) {
      v[x] += y;
      for (int i = 1; i < 500; i++) s[i][x % i] += y;
      ma = max(ma, x);
      mi = min(mi, x);
    } else {
      long long int res = 0;
      if (x >= 500) {
        for (int i = mi / x * x + y; i <= ma; i += x) res += v[i];
      } else
        res = s[x][y];
      printf("%I64d\n", res);
    }
  }
  return 0;
}
