#include <bits/stdc++.h>
using namespace std;
int rem[708][708];
int a[500009];
int main() {
  int q;
  scanf("%d", &q);
  int t, x, y;
  for (int i = 0; i < q; i++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d", &x);
      scanf("%d", &y);
      a[x] += y;
      for (int j = 1; j <= 707; j++) rem[j][x % j] += y;
    } else if (t == 2) {
      scanf("%d", &x);
      scanf("%d", &y);
      if (x <= 707)
        printf("%d\n", rem[x][y]);
      else {
        if (y == 0) y += x;
        int ans = 0;
        for (int j = y; j <= 500000; j += x) ans += a[j];
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}
