#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { long long K; string S; cin >> K >> S; int n = S.size(); if (K >= n) { cout << string(n, S[0]) << "\n"; } else { string result = S; for (int i = 0; i < K; i++) { result = result[0] + result.substr(0, n - 1); } cout << result << "\n"; } } return 0; }