#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
bool f(int pref[], string order, int reqlen, int l) {
  int len = l;
  for (int i = 0; i < order.size(); i++) {
    l -= pref[order[i] - 'a'];
    len += l;
  }
  return len == reqlen;
}
bool algo(string s, string t, string ord) {
  string res = s;
  for (int i = 0; i < ord.size(); i++) {
    char c = ord[i];
    string temp;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != c) temp += s[j];
    }
    s = temp;
    res += s;
    ;
  }
  return res == t;
}
void solve() {
  string s;
  cin >> s;
  bool vis[26];
  memset(vis, false, sizeof(vis));
  int n = s.size();
  string ord;
  for (int i = n - 1; i >= 0; i--) {
    if (!vis[s[i] - 'a']) {
      ord.push_back(s[i]);
      vis[s[i] - 'a'] = true;
    }
  }
  int dist = ord.size();
  memset(vis, false, sizeof(vis));
  int id;
  for (int i = 0; i < n; i++) {
    if (!vis[s[i] - 'a']) {
      id = i;
      vis[s[i] - 'a'] = true;
    }
  }
  int pref[26] = {0};
  for (int i = 0; i <= id; i++) pref[s[i] - 'a']++;
  reverse((ord).begin(), (ord).end());
  ;
  string ans = s.substr(0, id + 1);
  while (id < n) {
    if (f(pref, ord, s.size(), ans.size())) {
      if (algo(ans, s, ord)) {
        cout << ans << ' ' << ord << '\n';
        return;
      }
    }
    id++;
    if (id >= n) break;
    ans.push_back(s[id]);
    pref[s[id] - 'a']++;
  }
  cout << "-1\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  cin >> t;
  for (long long i = 1; i < t + 1; i++) {
    solve();
  }
  return 0;
}
