#include <bits/stdc++.h>
using namespace std;
const int N = 500050;
const int S = 700;
int sum[S][S], a[N];
int main() {
  int q;
  scanf("%i", &q);
  while (q--) {
    int t, x, y;
    scanf("%i %i %i", &t, &x, &y);
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i < S; i++) sum[i][x % i] += y;
    } else {
      if (x < S)
        printf("%i\n", sum[x][y]);
      else {
        int tmp = 0;
        for (int i = y; i < N; i += x) tmp += a[i];
        printf("%i\n", tmp);
      }
    }
  }
  return 0;
}
