#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  string letters = "";
  vector<int> count(26);
  reverse(s.begin(), s.end());
  for (char c : s) {
    count[c - 'a']++;
    if (count[c - 'a'] == 1) letters += c;
  }
  int len = 0, m = letters.size();
  for (int i = 0; i < m; i++) {
    if (count[letters[i] - 'a'] % (m - i)) {
      cout << "-1\n";
      return;
    }
    len += count[letters[i] - 'a'] / (m - i);
  }
  reverse(s.begin(), s.end());
  reverse(letters.begin(), letters.end());
  string ans = s.substr(0, len);
  string cur = ans;
  for (char c : letters) {
    string temp;
    for (char ch : cur) {
      if (ch != c) {
        temp += ch;
        ans += ch;
      }
    }
    cur = temp;
  }
  if (ans == s)
    cout << s.substr(0, len) << " " << letters << endl;
  else
    cout << "-1\n";
}
int32_t main() {
  int tc;
  cin >> tc;
  while (tc--) solve();
}
