#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 5e5 + 1, mid = 700;
int temp[mid + 10][mid + 10];
int a[maxn + 10];
int32_t main() {
  int n;
  cin >> n;
  while (n--) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i <= mid; ++i) {
        temp[i][x % i] += y;
      }
    } else if (t == 2) {
      int ans = 0;
      if (x > mid) {
        int curr = y;
        while (curr < maxn) {
          ans += a[curr];
          curr += x;
        }
      } else {
        ans += temp[x][y];
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
