#include using namespace std; using ll = long long; #ifdef LOCAL #include #else #define debug(...) #endif int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int T; cin >> T; while (T--) { int K; string S; cin >> K >> S; int N = ssize(S); if (K > N) { cout << string(N, S.front()) << "\n"; } else { while (K--) { S.insert(S.begin(), S.front()); S.pop_back(); } cout << S << "\n"; } } }