#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> a;
bool b[30];
int pos[30];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    a.clear();
    memset(b, 0, sizeof(b));
    memset(pos, 0, sizeof(pos));
    cin >> s;
    for (int i = s.size() - 1; i >= 0; i--) {
      if (!b[s[i] - 'a']) {
        b[s[i] - 'a'] = 1;
        a.push_back(s[i]);
      }
    }
    for (int i = 0; i < a.size(); i++) {
      pos[a[i] - 'a'] = a.size() - i;
    }
    int now = 0;
    string res;
    bool flag = 0;
    for (int i = 0; i < s.size(); i++) {
      res += s[i];
      now += pos[s[i] - 'a'];
      if (now > s.size()) break;
      if (now == s.size()) {
        string q, dex = res;
        for (int i = a.size() - 1; i >= 0; i--) {
          q += dex;
          string dey;
          for (int k = 0; k < dex.size(); k++) {
            if (dex[k] != a[i]) {
              dey += dex[k];
            }
          }
          dex = dey;
        }
        if (q == s) {
          flag = 1;
          break;
        }
      }
    }
    if (!flag)
      puts("-1");
    else {
      cout << res << " ";
      for (int i = a.size() - 1; i >= 0; i--) {
        printf("%c", a[i]);
      }
      cout << '\n';
    }
  }
  return 0;
}
