#include <bits/stdc++.h>
using namespace std;
//
const int mx = 5e5 + 5;
const int S = 700;
//
int q, type, x, y, a[mx];
long long sum[S][S];
//
void process (void)
{
    cin >> q;
    while (q--)
    {
        cin >> type >> x >> y;
        if (type == 1)
        {
            a[x] += y;
            for (int i = 1; i < S; ++i)
                sum[i][x % i] += y;
        }
        else
        {
            if (x < S)
                cout << sum[x][y];
            else
            {
                long long ans = 0;
                //
                for (int i = y; i < mx; i += x)
                    ans += a[i];
                cout << ans;
            }
            cout << '\n';
        }
    }
}
//
signed main (void)
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    process();
}