#include <bits/stdc++.h>
#include "testlib.h"
 
using namespace std;

struct Progress {
    long long tp, cur, y;

    bool operator<(Progress const &p) const {
        return cur < p.cur;
    }
};
 
int main(int argc, char *argv[]) {
    registerValidation(argc, argv);
    
    int k = inf.readInt(1, 100'000, "k");
    inf.readEoln();
    
    
    vector<pair<long long, long long>> b;
    
    for (int i = 0; i < k; ++i) {
        long long t, x, y;
        t = inf.readInt(1, 2, "t");
        inf.readSpace();
        x = inf.readInt(1, 100'000, "x");
        inf.readSpace();
        if (t == 1) {
            y = inf.readInt(1, 100'000, "d");
        } else {
            y = inf.readInt(2, 10, "q");
            b.emplace_back(x, y);
        }
        inf.readEoln();
    }
    
    int q;
    q = inf.readInt(1, 200'000, "q");
    inf.readEoln();
    vector<int> ids(q);
    for (int i = 0; i < q; ++i) {
        ids[i] = inf.readInt(0, 1'000'000, "i");
        inf.readEoln();
    }
    
    if (b.size() != k) {
        inf.readEof();
        return 0;
    }

    multiset<Progress> s;
    for (int i = 0; i < k; ++i) {
        s.insert({2, b[i].first, b[i].second});
    }
    
    int z = *max_element(ids.begin(), ids.end());

    vector<long long> ans(z + 1);
    for (int i = 0; i <= z; ++i) {
        ensuref(s.begin()->cur > 0, "overflow");
        ans[i] = s.begin()->cur;

        Progress z = *s.begin();
        s.erase(s.begin());
        if (z.tp == 1) z.cur += z.y;
        else z.cur *= z.y;

        s.insert(z);
    }
    
    inf.readEof();
}