#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() *
               ((uint64_t) new char | 1));
const int N = 100005;
int n, a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    bool b = 0;
    for (int i = 1; i < s.size(); i++) {
      if (s[i] != s[0]) {
        b = 1;
        swap(s[i], s[s.size() - 1]);
        break;
      }
    }
    if (b) {
      cout << s;
    } else {
      cout << -1;
    }
    cout << "\n";
  }
}
