#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const bool MULTI_TEST = false;
const int MAXN = 5e5;
const int SQN = 400;
unordered_map<int, int> clc[SQN];
int a[MAXN + 1];
void solve() {
  int q;
  cin >> q;
  int t, x, y;
  for (int i = 0; i < q; i++) {
    cin >> t >> x >> y;
    if (t == 2) {
      if (x < SQN) {
        cout << clc[x][y] << '\n';
      } else {
        int s = 0;
        for (int j = y; j <= MAXN; j += x) {
          s += a[j];
        }
        cout << s << '\n';
      }
    } else {
      a[x] += y;
      for (int j = 1; j < SQN; j++) {
        clc[j][x % j] += y;
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  int T = 1;
  if (MULTI_TEST) {
    cin >> T;
  }
  for (int i = 0; i < T; i++) {
    solve();
  }
  return 0;
}
