#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int flag = 0, i;
    string a;
    cin >> a;
    int sz = a.length();
    for (i = 1; i < sz; i++) {
      if (a[i] != a[i - 1]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0)
      cout << -1 << endl;
    else {
      int f = 0;
      for (int j = 0; j < sz; j++) {
        if (a[j] != a[sz - j - 1]) {
          f = 1;
          break;
        }
      }
      if (f == 1)
        cout << a << endl;
      else {
        char temp = a[i];
        a[i] = a[i - 1];
        a[i - 1] = temp;
        cout << a << endl;
      }
    }
  }
}
