#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, MAXN = 5e5 + 10, SIZE = 80;
int N = 5e5, M, a[MAXN], sum[SIZE][SIZE];
int main() {
  scanf("%d", &M);
  int siz = pow(N, 0.33);
  while (M--) {
    int op, x, y;
    scanf("%d%d%d", &op, &x, &y);
    if (op == 2) {
      if (x <= siz) {
        printf("%d\n", sum[x][y]);
      } else {
        int ret = 0;
        for (int i = y; i <= N; i += x) {
          ret += a[i];
        }
        printf("%d\n", ret);
      }
    } else {
      for (int i = 1; i <= siz; i++) {
        sum[i][x % i] += y;
      }
      a[x] += y;
    }
  }
  return 0;
}
