#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int a[26];
    memset(a, 0, sizeof(a));
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
      if (a[s[i] - 'a'] == 0) cnt++;
      a[s[i] - 'a']++;
    }
    if (cnt == 1)
      cout << -1;
    else {
      for (int i = 0; i < 26; i++) {
        while (a[i]--) {
          cout << char(i + 'a');
        }
      }
    }
    cout << endl;
  }
}
