#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, NegOO = -1 * OO, N = 1e5 + 5, mod = 1e9 + 7;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string x;
    cin >> x;
    int dif = 0;
    sort(((x).begin()), ((x).end()));
    for (int i = 1; i < ((int)((x).size())); ++i) {
      if (x[i] != x[i - 1]) dif++;
    }
    if (!dif) {
      cout << -1 << "\n";
      continue;
    }
    cout << x << "\n";
  }
  return 0;
}
