#include <bits/stdc++.h>
void merge(char arr[], int left, int right, int mid) {
  int L = left;
  int R = mid + 1;
  char temp[1005];
  int tempIndex = 0;
  while (L <= mid && R <= right) {
    if (arr[L] < arr[R]) {
      temp[tempIndex++] = arr[L++];
    } else {
      temp[tempIndex++] = arr[R++];
    }
  }
  while (L <= mid) {
    temp[tempIndex++] = arr[L++];
  }
  while (R <= right) {
    temp[tempIndex++] = arr[R++];
  }
  for (int i = left, j = 0; i <= right; i++, j++) {
    arr[i] = temp[j];
  }
}
void mergeSort(char arr[], int left, int right) {
  if (left == right) return;
  int mid = (left + right) / 2;
  mergeSort(arr, left, mid);
  mergeSort(arr, mid + 1, right);
  merge(arr, left, right, mid);
}
int main() {
  int tc;
  scanf("%d", &tc);
  getchar();
  char s[1005];
  char x[1005];
  int len;
  int idx = 0;
  int temp = 0;
  for (int i = 0; i < tc; i++) {
    scanf("%s", s);
    getchar();
    len = strlen(s);
    for (int j = len - 1; j >= 0; j--) {
      if (s[j] == s[idx]) idx++;
    }
    if (idx == len) {
      mergeSort(s, 0, len - 1);
      for (int j = len - 1; j >= 0; j--) {
        if (s[j] == s[temp]) temp++;
      }
      if (temp == len)
        printf("-1\n");
      else
        printf("%s\n", s);
      temp = 0;
    } else
      printf("%s\n", s);
    idx = 0;
  }
  return 0;
}
