#include <bits/stdc++.h>
const double eps = 1e-9;
const double PI = acos(-1);
const long long MOD = 1e9 + 7;
using namespace std;
vector<string> powers;
pair<string, string> solution(string s) {
  string order;
  reverse(s.begin(), s.end());
  map<char, int> mp;
  for (char c : s) {
    if (!mp[c]) {
      order.push_back(c);
    }
    mp[c]++;
  }
  int m = order.length();
  int original_size = 0;
  for (int i = 0; i < m; i++) {
    original_size += mp[order[i]] / (m - i);
  }
  reverse(order.begin(), order.end());
  return {string(s.rbegin(), s.rbegin() + original_size), order};
}
string check(pair<string, string> p) {
  string result = p.first;
  for (auto c : p.second) {
    string tmp;
    for (auto d : p.first) {
      if (d != c) {
        tmp.push_back(d);
        result.push_back(d);
      }
    }
    p.first = tmp;
  }
  return result;
}
void solve() {
  string s;
  cin >> s;
  auto it = solution(s);
  auto res = check(it);
  if (res == s) {
    cout << it.first << " " << it.second << endl;
  } else {
    cout << -1 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 1; i <= 2e18; i *= 2) {
    powers.push_back(to_string(i));
  }
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
