#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char ch = getchar(), w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
using namespace std;
const int N = 510000;
int op, x, y;
long long f[800][800];
long long a[N];
int main() {
  int Q = read();
  while (Q--) {
    op = read(), x = read(), y = read();
    if (op == 1) {
      a[x] += y;
      for (int i = 1; i <= 799; ++i) f[i][x % i] += y;
    } else {
      long long ans = 0;
      if (x > 799) {
        for (int i = y; i <= 500000; i += x) ans += a[i];
        writeln(ans);
      } else
        writeln(f[x][y]);
    }
  }
  return 0;
}
