#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int N = 1e6 + 5;
const int ha = 998244353;
int f[1000][1000], Q, a, b, c;
int A[N];
int32_t main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> Q;
  while (Q--) {
    cin >> a >> b >> c;
    if (a == 1) {
      A[b] += c;
      for (int i = 1; i < 1000; ++i) f[i][b % i] += c;
    } else {
      if (b < 1000)
        printf("%d\n", f[b][c]);
      else {
        int res = 0;
        for (int i = c; i <= 500000; i += b) res += A[i];
        printf("%d\n", res);
      }
    }
  }
}
