#include <bits/stdc++.h>
using namespace std;
int n;
int n1, n2, n3;
int v[500010];
int mod[710][710];
int main() {
  scanf("%d", &n);
  for (int g = 1; g <= n; g++) {
    scanf("%d %d %d", &n1, &n2, &n3);
    if (n1 == 1) {
      v[n2] += n3;
      for (int i = 1; i < 710; i++) mod[i][n2 % i] += n3;
    }
    if (n1 == 2) {
      int ans = 0;
      if (n2 < 710)
        ans = mod[n2][n3];
      else {
        for (int i = n3; i < 500010; i += n2) ans += v[i];
      }
      printf("%d\n", ans);
    }
  }
}
