#include <bits/stdc++.h>
using namespace std;
const int INF = 1073741823;
const long double PI = 3.1415926535898;
const long long oo = 4611686018427387903;
const int N = 500000;
const int K = 750;
int q;
int a[N + 5];
int f[K + 5][K + 5];
void add(int x, int y) {
  a[x] += y;
  for (int i = 1; i <= K; i++) {
    f[i][x % i] += y;
  }
}
void query(int x, int y) {
  if (x > K) {
    long long ans = 0;
    for (int i = y; i <= N; i += x) {
      ans += a[i];
    }
    cout << ans << '\n';
  } else
    cout << f[x][y] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(a, 0, sizeof(a));
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1)
      add(x, y);
    else
      query(x, y);
  }
}
