#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int LEN = 500000;
const int SIZE = 500;
int n;
ll a[LEN + 1];
ll sum[3001][3001];
template <typename T>
inline T read() {
  T x = 0;
  T multiplier = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      multiplier = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch & 15);
    ch = getchar();
  }
  return x * multiplier;
}
int main() {
  n = read<int>();
  for (int i = 1; i <= n; i++) {
    int op = read<int>(), x = read<int>(), y = read<int>();
    if (op == 1) {
      a[x] += y;
      for (int j = 1; j <= SIZE; j++) {
        sum[j][x % j] += y;
      }
    } else if (op == 2) {
      ll ans = 0;
      if (x <= SIZE) {
        ans += 1LL * sum[x][y];
      } else {
        for (int j = y; j <= LEN; j += x) {
          ans += 1LL * a[j];
        }
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}
