#include <bits/stdc++.h>
using namespace std;
clock_t time_p = clock();
void timer() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "sec\n";
}
const long long INF = 1e18 + 1;
long long expo(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x;
    res %= 1000000007;
    y = y >> 1;
    x = x * x;
    x %= 1000000007;
  }
  return res;
}
long long smod(long long a, long long md = 1000000007) {
  a = a % md;
  if (a < 0) a += md;
  return a;
}
long long nCk(long long n, long long k) {
  long long res = 1;
  if (k > n - k) k = n - k;
  for (long long i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
bool vis[26];
int freq[26];
void south_pole() {
  int i, n;
  string s, t, tt, order, ans;
  cin >> t;
  n = (int)(t).size();
  memset(freq, 0, sizeof(freq));
  memset(vis, false, sizeof(vis));
  for (i = n - 1; i >= 0; i--) {
    if (!vis[t[i] - 'a']) {
      vis[t[i] - 'a'] = true;
      order.push_back(t[i]);
    }
    freq[t[i] - 'a']++;
  }
  reverse(order.begin(), order.end());
  int len = 0;
  for (int i = 0; i < order.size(); i++) {
    if (freq[order[i] - 'a'] % (i + 1) != 0) {
      cout << -1 << '\n';
      return;
    }
    len += freq[order[i] - 'a'] / (i + 1);
  }
  s = t.substr(0, len);
  ans = s;
  tt = s;
  for (i = 0; i < order.size(); i++) {
    string temp;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != order[i]) temp.push_back(s[j]);
    }
    s = temp;
    tt = tt + s;
  }
  if (tt == t)
    cout << ans << ' ' << order << '\n';
  else
    cout << -1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    south_pole();
  }
  timer();
  return 0;
}
