#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Type>
struct is_vector : std::false_type {};
template <class ValueType, class Alloc>
struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T>
inline ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.empty()) return out;
  constexpr bool is_vector_v = is_vector<T>::value;
  if (is_vector_v)
    for (auto itr = v.begin(); itr != v.end();)
      out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
  else
    for (auto itr = v.begin(); itr != v.end();)
      out << (*itr), out << ((++itr != v.end()) ? " " : "");
  return out;
}
inline void put() {}
template <class T>
inline void put(const T& first) {
  std::cout << first << "\n";
}
template <class T, class... N>
inline void put(const T& first, const N&... rest) {
  std::cout << first << " ";
  put(rest...);
}
inline void putn() {}
template <class T, class... N>
inline void putn(const T& first, const N&... rest) {
  std::cout << first << "\n";
  putn(rest...);
}
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int q;
  cin >> q;
  int qn = 700;
  int n = 5e5 + 1;
  vector<vector<long long>> s(qn);
  vector<long long> a(n, 0);
  for (long long i = 0; i < (long long)(qn); i++) {
    s[i].resize(i + 1);
    fill((s[i]).begin(), (s[i]).end(), 0);
  }
  for (long long i = 0; i < (long long)(q); i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      for (long long i = 0; i < (long long)(qn); i++) {
        s[i][x % (i + 1)] += y;
      }
      a[x] += y;
    } else {
      if (x <= qn) {
        long long res = s[x - 1][y];
        put(res);
      } else {
        long long res = 0;
        for (int i = y; i < n; i += x) {
          res += a[i];
        }
        put(res);
      }
    }
  }
  return 0;
}
