#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int len = s.size(), pan = 0, cnt = 0;
    int mid = (len / 2) - 1;
    for (int i = 0, j = len - 1; i <= mid; i++, j--) {
      if (s[i] != s[j]) {
        pan = 1;
        break;
      }
    }
    if (pan == 0) {
      for (int i = 0; i < len - 1; i++) {
        if (s[i] != s[i + 1]) {
          swap(s[i], s[i + 1]);
        } else {
          cnt++;
        }
      }
      if (cnt == (len - 1)) {
        cout << "-1" << endl;
      } else {
        cout << s << endl;
      }
    } else {
      cout << s << endl;
    }
  }
  return 0;
}
