#include <bits/stdc++.h>
using namespace std;
int dp[721][721], ara[500001];
int main() {
  int i, j, k;
  int q;
  int t, x, y;
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &t, &x, &y);
    if (t == 1) {
      ara[x] += y;
      for (j = 1; j <= 720; j++) dp[j][x % j] += y;
    } else {
      if (x <= 720)
        printf("%d\n", dp[x][y]);
      else {
        int sum = 0;
        for (j = 0; y + j * x <= 500000; j++) sum += ara[y + j * x];
        printf("%d\n", sum);
      }
    }
  }
}
