#include <bits/stdc++.h>
using namespace std;
const int block = 800;
const int lim = 500005 - 5;
int q;
long long a[500005];
long long f[1005][1005];
int main() {
  scanf("%d", &q);
  while (q-- > 0) {
    int id, first, second;
    scanf("%d %d %d", &id, &first, &second);
    if (id == 1) {
      for (int i = 1; i <= block; ++i) f[i][first % i] += second;
      a[first] += second;
    }
    if (id == 2) {
      if (first > block) {
        long long ret = 0;
        for (int i = second; i <= lim; i += first) {
          ret += a[i];
        }
        printf("%I64d\n", ret);
      } else {
        printf("%I64d\n", f[first][(second % first + first) % first]);
      }
    }
  }
}
