#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 500000;
const int maxsn = 707;
int ans[maxsn][maxsn];
int a[maxn];
long long res;
int main() {
  int q;
  scanf("%d", &q);
  int t, x, y;
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1) {
      a[x] += y;
      for (int i = 1; i < maxsn; i++) ans[i][x % i] += y;
    } else {
      res = 0;
      if (x >= maxsn)
        for (int i = y; i <= maxn; i += x) res += a[i];
      else
        res = ans[x][y];
      printf("%lld\n", res);
    }
  }
  return 0;
}
