#include <bits/stdc++.h>
using namespace std;
const int mx = 1000005;
stack<int> stk;
map<int, int> mp;
int arr[mx];
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    string str;
    cin >> str;
    int i;
    for (i = 1; i < str.size(); i++) {
      if (str[0] == str[i])
        continue;
      else
        break;
    }
    if (str[0] != str[str.size() - 1])
      cout << str << endl;
    else if (str[0] == str[str.size() - 1] and i != str.size()) {
      swap(str[i], str[str.size() - 1]);
      cout << str << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
