#include <bits/stdc++.h>
using namespace std;
void file_i_o() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
vector<int> primeFactorization(int n) {
  vector<int> arr;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) arr.push_back(i);
  }
  return arr;
}
int main() {
  int x, n;
  scanf("%d", &n);
  while (n--) {
    string s;
    cin >> s;
    string ori = s;
    int l = s.length();
    bool can = false;
    string ran = s;
    for (int i = (0); i < (l); i++) {
      reverse(ran.begin(), ran.end());
      if (s != ran) {
        can = true;
        break;
      } else {
        int c = 0;
        for (int j = (i + 1); j < (l); j++) {
          ran[c] = s[j];
          c++;
        }
        for (int j = (0); j < (i + 1); j++) {
          ran[c] = s[j];
          c++;
        }
        s = ran;
      }
    }
    if (can) {
      cout << s << endl;
    } else {
      printf("%d \n", -1);
    }
  }
  return 0;
}
