#include <bits/stdc++.h>
using namespace std;
int main() {
  int tst;
  cin >> tst;
  while (tst--) {
    string str;
    cin >> str;
    bool flg = 1;
    for (int i = 1; i < str.size(); i++)
      if (str[i] != str[i - 1]) flg = 0;
    if (flg) {
      cout << -1 << endl;
      continue;
    }
    string rev = str;
    reverse(rev.begin(), rev.end());
    if (str != rev) {
      cout << str << endl;
      continue;
    }
    char p1 = str[0];
    int swp = 0;
    for (int i = 1; i < str.size(); i++)
      if (str[i] != p1) {
        swp = i;
        break;
      }
    swap(str[0], str[swp]);
    cout << str << endl;
  }
}
