#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    bool same = true;
    int diff = -1;
    for (int i = 1; s[i]; i++) {
      if (s[i] != s[0]) {
        diff = i;
        break;
      }
    }
    if (diff == -1) {
      cout << -1;
      cout << "\n";
    } else {
      cout << s[0];
      for (int i = 1; i < s.length(); i++) {
        if (i == diff) continue;
        cout << s[i];
      }
      cout << s[diff] << "\n";
    }
  }
  return 0;
}
