#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int freq[27];
  int t;
  cin >> t;
  while (t--) {
    memset(freq, 0, sizeof(freq));
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
      int x = (int)(s[i] - 'a');
      freq[x]++;
    }
    bool p = true;
    for (int i = 0; i < 26; i++) {
      if (freq[i] == s.size()) {
        p = false;
        break;
      }
    }
    if (p == false) {
      cout << "-1\n";
    } else {
      for (int i = 0; i < 26; i++) {
        for (int j = 0; j < freq[i]; j++) {
          cout << (char)('a' + i);
        }
      }
      cout << endl;
    }
  }
  return 0;
}
