description: Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):
  
    * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; 
    * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). 
  
  
  
  Polycarp performs this sequence of actions strictly in this order.
  
  Note that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).
  
  E.g. consider s="abacaba" so the actions may be performed as follows:
  
    * t="abacaba", the letter 'b' is selected, then s="aacaa"; 
    * t="abacabaaacaa", the letter 'a' is selected, then s="c"; 
    * t="abacabaaacaac", the letter 'c' is selected, then s="" (the empty string). 
  
  
  
  You need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.
  
  Input
  
  The first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.
  
  Each test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.
  
  Output
  
  For each test case output in a separate line:
  
    * -1, if the answer doesn't exist; 
    * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string "bac" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one. 
  
  Example
  
  Input
  
  
  7
  abacabaaacaac
  nowyouknowthat
  polycarppoycarppoyarppyarppyrpprppp
  isi
  everywherevrywhrvryhrvrhrvhv
  haaha
  qweqeewew
  
  
  Output
  
  
  abacaba bac
  -1
  polycarp lcoayrp
  is si
  everywhere ewyrhv
  -1
  -1
  
  Note
  
  The first test case is considered in the statement.
solution: import java.io.*;
  import java.util.*;
  
  public final class Main {
  
      static PrintWriter out = new PrintWriter(System.out);
      static FastReader in = new FastReader();
      static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};
  
      //7
      //abacabaaacaac
      //nowyouknowthat
      //polycarppoycarppoyarppyarppyrpprppp
      //isi
      //everywherevrywhrvryhrvrhrvhv
      //haaha
      //qweqeewew
  
      //vhrywe
      // v hv rhrv
  
      public static void main(String[] args) {
          int tt = i();
          int mod = (int) (1e9 + 7);
  
          loop:
          while (tt-- > 0) {
              String s = s();
              int[] cnt = new int[26];
              List<Integer> order = new LinkedList<>();
              for (int i = s.length() - 1; i >= 0; i--) {
                  int cur = s.charAt(i) - 'a';
                  if (cnt[cur] == 0) {
                      order.add(cur);
                  }
                  cnt[cur]++;
              }
              int len = 0;
              int m = 1;
              StringBuilder sb2 = new StringBuilder();
              for (int i = order.size() - 1; i >= 0; i--) {
                  int cur = order.get(i);
                  len += cnt[cur] / m;
                  m++;
                  sb2.append((char) ('a' + cur));
              }
              String s1 = s.substring(0, len);
              String s2 = sb2.toString();
  
              StringBuilder ans = new StringBuilder();
              String tmp = s1;
              for (int i = order.size() - 1; i >= 0; i--) {
                  ans.append(tmp);
                  int cur = order.get(i);
                  char c = (char) ('a' + cur);
                  StringBuilder newTmp = new StringBuilder();
                  for (char cc : tmp.toCharArray()) {
                      if (cc != c) {
                          newTmp.append(cc);
                      }
                  }
                  tmp = newTmp.toString();
              }
              if (ans.toString().equals(s)) {
                  out.println(s1 + " " + s2);
              } else {
                  out.println(-1);
              }
          }
          out.flush();
      }
  
  
      static int[] pre(int[] a) {
          int[] pre = new int[a.length];
          pre[0] = a[0];
          for (int i = 1; i < a.length; i++) {
              pre[i] = pre[i - 1] + a[i];
          }
          return pre;
      }
  
      static int[] preRev(int[] a) {
          int[] pre = new int[a.length];
          pre[a.length - 1] = a[a.length - 1];
          for (int i = a.length - 2; i >= 0; i--) {
              pre[i] = pre[i + 1] + a[i];
          }
          return pre;
      }
  
      static void print(char A[]) {
          for (char c : A) {
              out.print(c);
          }
          out.println();
      }
  
      static void print(boolean A[]) {
          for (boolean c : A) {
              out.print(c + " ");
          }
          out.println();
      }
  
      static void print(int A[]) {
          for (int c : A) {
              out.print(c + " ");
          }
          out.println();
      }
  
      static void print(long A[]) {
          for (long i : A) {
              out.print(i + " ");
          }
          out.println();
      }
  
      static void print(List<Integer> A) {
          for (int a : A) {
              out.print(a + " ");
          }
      }
  
      static void printYes() {
          out.println("YES");
      }
  
      static void printNo() {
          out.println("NO");
      }
  
      static int i() {
          return in.nextInt();
      }
  
      static long l() {
          return in.nextLong();
      }
  
      static String s() {
          return in.nextLine();
      }
  
      static int[][] inputWithIdx(int N) {
          int A[][] = new int[N][2];
          for (int i = 0; i < N; i++) {
              A[i] = new int[]{i, in.nextInt()};
          }
          return A;
      }
  
      static int[] input(int N) {
          int A[] = new int[N];
          for (int i = 0; i < N; i++) {
              A[i] = in.nextInt();
          }
          return A;
      }
  
      static long[] inputLong(int N) {
          long A[] = new long[N];
          for (int i = 0; i < A.length; i++) {
              A[i] = in.nextLong();
          }
          return A;
      }
  
      static int GCD(int a, int b) {
          if (b == 0) {
              return a;
          } else {
              return GCD(b, a % b);
          }
      }
  
      static long GCD(long a, long b) {
          if (b == 0) {
              return a;
          } else {
              return GCD(b, a % b);
          }
      }
  
      static long LCM(int a, int b) {
          return (long) a / GCD(a, b) * b;
      }
  
      static long LCM(long a, long b) {
          return a / GCD(a, b) * b;
      }
  
      static void shuffleAndSort(int[] arr) {
          for (int i = 0; i < arr.length; i++) {
              int rand = (int) (Math.random() * arr.length);
              int temp = arr[rand];
              arr[rand] = arr[i];
              arr[i] = temp;
          }
          Arrays.sort(arr);
      }
  
      static void shuffleAndSort(int[][] arr, Comparator<? super int[]> comparator) {
          for (int i = 0; i < arr.length; i++) {
              int rand = (int) (Math.random() * arr.length);
              int[] temp = arr[rand];
              arr[rand] = arr[i];
              arr[i] = temp;
          }
          Arrays.sort(arr, comparator);
      }
  
      static void shuffleAndSort(long[] arr) {
          for (int i = 0; i < arr.length; i++) {
              int rand = (int) (Math.random() * arr.length);
              long temp = arr[rand];
              arr[rand] = arr[i];
              arr[i] = temp;
          }
          Arrays.sort(arr);
      }
  
      static boolean isPerfectSquare(double number) {
          double sqrt = Math.sqrt(number);
          return ((sqrt - Math.floor(sqrt)) == 0);
      }
  
      static void swap(int A[], int a, int b) {
          int t = A[a];
          A[a] = A[b];
          A[b] = t;
      }
  
      static long pow(long a, long b, int mod) {
          long pow = 1;
          long x = a;
          while (b != 0) {
              if ((b & 1) != 0) {
                  pow = (pow * x) % mod;
              }
              x = (x * x) % mod;
              b /= 2;
          }
          return pow;
      }
  
      static long pow(long a, long b) {
          long pow = 1;
          long x = a;
          while (b != 0) {
              if ((b & 1) != 0) {
                  pow *= x;
              }
              x = x * x;
              b /= 2;
          }
          return pow;
      }
  
      static long modInverse(long x, int mod) {
          return pow(x, mod - 2, mod);
      }
  
      static boolean isPrime(long N) {
          if (N <= 1) {
              return false;
          }
          if (N <= 3) {
              return true;
          }
          if (N % 2 == 0 || N % 3 == 0) {
              return false;
          }
          for (int i = 5; i * i <= N; i = i + 6) {
              if (N % i == 0 || N % (i + 2) == 0) {
                  return false;
              }
          }
          return true;
      }
  
      public static String reverse(String str) {
          if (str == null) {
              return null;
          }
          return new StringBuilder(str).reverse().toString();
      }
  
      public static String repeat(char ch, int repeat) {
          if (repeat <= 0) {
              return "";
          }
          final char[] buf = new char[repeat];
          for (int i = repeat - 1; i >= 0; i--) {
              buf[i] = ch;
          }
          return new String(buf);
      }
  
      public static int[] manacher(String s) {
          char[] chars = s.toCharArray();
          int n = s.length();
          int[] d1 = new int[n];
          for (int i = 0, l = 0, r = -1; i < n; i++) {
              int k = (i > r) ? 1 : Math.min(d1[l + r - i], r - i + 1);
              while (0 <= i - k && i + k < n && chars[i - k] == chars[i + k]) {
                  k++;
              }
              d1[i] = k--;
              if (i + k > r) {
                  l = i - k;
                  r = i + k;
              }
          }
          return d1;
      }
  }
  
  class Pair {
  
      int i, j;
  
      Pair(int i, int j) {
          this.i = i;
          this.j = j;
      }
  }
  
  class FastReader {
  
      BufferedReader br;
      StringTokenizer st;
  
      public FastReader() {
          br = new BufferedReader(new InputStreamReader(System.in));
      }
  
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
  
      int nextInt() {
          return Integer.parseInt(next());
      }
  
      long nextLong() {
          return Long.parseLong(next());
      }
  
      double nextDouble() {
          return Double.parseDouble(next());
      }
  
      String nextLine() {
          String str = "";
          try {
              str = br.readLine();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return str;
      }
  }