#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 123;
int k, n, x, m, t, a[maxN], ans;
string s;
pair<string, int> p[maxN];
string check(string s, int k) {
  n = s.size();
  string t = "";
  for (int i = k - 1; i < n; i++) {
    t += s[i];
  }
  if ((n - k) % 2) {
    for (int i = 0; i < k - 1; i++) t += s[i];
  } else {
    for (int i = k - 2; i >= 0; i--) t += s[i];
  }
  return t;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> s;
    for (int i = 1; i <= n; i++) {
      p[i].first = check(s, i);
      p[i].second = i;
    }
    sort(p + 1, p + n + 1);
    cout << p[1].first << endl << p[1].second << endl;
  }
  return 0;
}
