#include <bits/stdc++.h>
using namespace std;
inline long long getnum() {
  char c = getchar();
  long long num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
int A[500005];
int B[704][704];
int main() {
  int q = getnum();
  for (int i = 1; i <= q; i++) {
    int t = getnum(), x = getnum(), y = getnum();
    if (t == 1) {
      A[x] += y;
      for (int i = 1; i <= 288; i++) {
        B[i][x % i] += y;
      }
    } else {
      int ans = 0;
      if (x > 288) {
        for (int i = y; i <= 500000; i += x) ans += A[i];
      } else {
        ans = B[x][y];
      }
      printf("%d\n", ans);
    }
  }
}
