/* ---------------- Competitive Programming Template for ICPC and Other Competitions ---------------- */ #include #define _USE_MATH_DEFINES #include #include #include #include using namespace std; /* ------------------- FAST I/O ------------------- */ #define fast_io ios::sync_with_stdio(false);cin.tie(nullptr) /* ------------------- TYPE ALIASES ------------------- */ using ll = long long; using lld = long double; using vll = vector; using vlld = vector; using vb = vector; using vvll = vector>; using vvlld = vector>; using pll = pair; /* ------------------- MACROS ------------------- */ #define rep(i,a,b) for(ll i=(a);i<(b);++i) #define per(i,a,b) for(ll i=(a);i>=(b);--i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pb push_back #define eb emplace_back #define fi first #define se second #define sz(x) ((ll)(x).size()) #define nl "\n" /* ------------------- CONSTANTS ------------------- */ const ll MOD = 1e9 + 7; const ll INF = LLONG_MAX; /* --------------- GCD and LCM --------------- */ inline ll gcd(ll a,ll b){ return b ? gcd(b,a%b) : a; } inline ll lcm(ll a,ll b){ return (a/gcd(a,b))*b; } /* --------------- FASTER INPUT/OUTPUT --------------- */ namespace __input { template void re(T &x){ cin >> x; } void re(lld &x){ string t; cin >> t; x=stold(t); } template void re(pair &p){ re(p.first,p.second); } template void re(vector &a){ for(auto &x:a) re(x); } template void re(array &a){ for(auto &x:a) re(x); } template void re(Arg &f,Args &...r){ re(f); re(r...); } } using namespace __input; namespace __output { template void pr(const T &x){ cout< void pr(const pair &p){ pr(p.first);pr(" ");pr(p.second); } template void pr(const Arg &f,const Args &...r){ pr(f);pr(" ");pr(r...); } template void pr(const vector &x){ for(const auto &a:x){ pr(a); pr(" "); } } void ps(){ pr("\n"); } template void ps(const Arg &f){ pr(f); ps(); } template void ps(const Arg &f,const Args &...r){ pr(f); pr(" "); ps(r...); } } using namespace __output; /* --------------- RANDOM HELPER --------------- */ mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); inline ll random_in_range(ll l,ll r){ uniform_int_distribution dist(l,r); return dist(rng); } /* --------------- SOLVE --------------- */ void solve(){ ll N; re(N); string ss; re(ss); vll arr(N); re(arr); string ans;ans.clear(); rep(i, 0, N) { ll x = arr[i]; --x; ans.append(1, ss[x]); } ps(ans); } /* --------------- MAIN --------------- */ int main(){ fast_io; #if defined(LOCAL) && LOCAL == SALMAN // Record start time auto start = std::chrono::high_resolution_clock::now(); #endif // // Precomputations Needed for Your Code // precompute_factorials(); // ? Required for nCr(n, r) // sieve(MAXN); // ? Required for prime-related functions // compute_totient(); // ? Required for ?(n) calculations // compute_mobius(); // ? Required for Möbius function calculations cout << setprecision(12) << fixed; ll T=1; // cin >> T; while(T--) solve(); #if defined(LOCAL) && LOCAL == SALMAN // Record end time auto end = std::chrono::high_resolution_clock::now(); // Calculate duration std::chrono::duration duration = end - start; // Output duration in seconds std::cout << "Execution time: " << duration.count() << " seconds" << std::endl; #endif return 0; }