#include using namespace std; string shift_once(const string &S) { return S[0] + S.substr(0, S.size() - 1); } 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; }