#include <bits/stdc++.h>
const int maxn = 500010;
int a[maxn];
long long s[1000][1000];
int main() {
  int k = sqrt(500000), q, o, x, y;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &o, &x, &y);
    if (o == 1) {
      a[x] += y;
      for (int i = 1; i <= k; ++i) s[i][x % i] += y;
    } else {
      if (x > k) {
        long long ans = 0;
        for (int i = y; i <= 500000; i += x) ans += a[i];
        printf("%I64d\n", ans);
      } else {
        printf("%I64d\n", s[x][y]);
      }
    }
  }
  return 0;
}
