#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cin.clear();
    string s;
    cin >> s;
    long long len = s.length();
    long long k = 2;
    long long save = 1;
    string s1 = s;
    string s2 = s;
    std::reverse(s1.begin(), s1.end());
    while (k <= n) {
      char q = s[0];
      if (n != k) {
        for (int i = 0; i < len - 1; i++) s[i] = s[i + 1];
        if (n % 2 == 0) {
          if (k % 2 == 0) {
            s[len - 1] = q;
            std::reverse(s.end() - (k - 1), s.end());
          } else {
            std::reverse(s.end() - (k - 1), s.end() - 1);
            s[len - 1] = q;
          }
        } else {
          if (k % 2 != 0) {
            s[len - 1] = q;
            std::reverse(s.end() - (k - 1), s.end());
          } else {
            std::reverse(s.end() - (k - 1), s.end() - 1);
            s[len - 1] = q;
          }
        }
      } else if (k == n)
        s = s1;
      if (s2 > s) {
        s2 = s;
        save = k;
      }
      k++;
    }
    cout << s2 << endl << save << endl;
  }
}
