description: Polycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):
  
    * he adds to the right to the string t the string s, i.e. he does t = t + s, where t + s is a concatenation of the strings t and s; 
    * he selects an arbitrary letter of s and removes from s all its occurrences (the selected letter must occur in the string s at the moment of performing this action). 
  
  
  
  Polycarp performs this sequence of actions strictly in this order.
  
  Note that after Polycarp finishes the actions, the string s will be empty and the string t will be equal to some value (that is undefined and depends on the order of removing).
  
  E.g. consider s="abacaba" so the actions may be performed as follows:
  
    * t="abacaba", the letter 'b' is selected, then s="aacaa"; 
    * t="abacabaaacaa", the letter 'a' is selected, then s="c"; 
    * t="abacabaaacaac", the letter 'c' is selected, then s="" (the empty string). 
  
  
  
  You need to restore the initial value of the string s using only the final value of t and find the order of removing letters from s.
  
  Input
  
  The first line contains one integer T (1 ≤ T ≤ 10^4) — the number of test cases. Then T test cases follow.
  
  Each test case contains one string t consisting of lowercase letters of the Latin alphabet. The length of t doesn't exceed 5 ⋅ 10^5. The sum of lengths of all strings t in the test cases doesn't exceed 5 ⋅ 10^5.
  
  Output
  
  For each test case output in a separate line:
  
    * -1, if the answer doesn't exist; 
    * two strings separated by spaces. The first one must contain a possible initial value of s. The second one must contain a sequence of letters — it's in what order one needs to remove letters from s to make the string t. E.g. if the string "bac" is outputted, then, first, all occurrences of the letter 'b' were deleted, then all occurrences of 'a', and then, finally, all occurrences of 'c'. If there are multiple solutions, print any one. 
  
  Example
  
  Input
  
  
  7
  abacabaaacaac
  nowyouknowthat
  polycarppoycarppoyarppyarppyrpprppp
  isi
  everywherevrywhrvryhrvrhrvhv
  haaha
  qweqeewew
  
  
  Output
  
  
  abacaba bac
  -1
  polycarp lcoayrp
  is si
  everywhere ewyrhv
  -1
  -1
  
  Note
  
  The first test case is considered in the statement.
solution: 
  import java.io.*;
  import java.util.*;
  public class A {
  
  	static Scanner sc=new Scanner(System.in);
  	//static Reader sc=new Reader();
  	static StringBuilder out=new StringBuilder();
  	public static void main(String[] args) throws IOException {
  		// TODO Auto-generated method stub
  		
  		int t=sc.nextInt();
  		
  		while(t-->0) {
  		A run=new A();
  		
  		run.run();
  		}
  		
  		System.out.println(out);
   		
  
  	}
  	static int a[][];
  	
  	static class pair implements Comparable <pair> {
  
  		int f,  s;
  		
  		pair(int f, int s){
  			this.f=f;
  			this.s=s;
  			
  		}
  		@Override
  		public int compareTo(pair o) {
  			// TODO Auto-generated method stub
  			return 0;
  		}
  		
  	}
  	
  	TreeSet<pair> gr[];
  	
  	public void run() throws IOException {
  			
  		
  		String s=sc.next();
  		
  		int freq[]=new int[26];
  		int cnt=0;
  		
  		for(int i=0;i<s.length();i++) {
  			
  			freq[s.charAt(i)-'a']++;
  			if(freq[s.charAt(i)-'a']==1)cnt++;
  		}
  		
  		HashMap<Character,Integer> hm=new HashMap<>();
  		
  		StringBuilder st=new StringBuilder();
  		StringBuilder ans=new StringBuilder();
  		st.append(s);
  		
  		int count[]=new int[26];
  		boolean ok=true;
  		
  		while(st.length()>0) {
  			
  			
  			StringBuilder tem=new StringBuilder();
  			int temCount=0;
  			int n=st.length()-1;
  			ans.append(st.charAt(n));
  			for(int i=0;i<st.length();i++) {
  				
  				
  				if(st.charAt(i)!=st.charAt(n))tem.append(st.charAt(i));
  				else {
  					temCount++;
  				}
  				
  			}
  			
  			if(temCount%cnt!=0)ok=false;
  			count[st.charAt(n)-'a']=temCount/cnt;
  			cnt--;
  			st=tem;
  			
  		}
  		
  		int dp[]=new int[26];
  		int id=-1;
  		st=new StringBuilder();
  		
  		for(int i=0;i<s.length();i++) {
  			
  			
  			if(dp[s.charAt(i)-'a']+1<=count[s.charAt(i)-'a']) {
  				dp[s.charAt(i)-'a']++;
  				st.append(s.charAt(i));
  				id=i;
  			}
  			else break;
  			
  		}
  		
  		
  //		for(int i=0;i<26;i++) {
  //			
  //			if(dp[i]!=0 && dp[i]<count[i]) {
  //				ok=false;
  //				break;
  //			}
  //			
  //		}
  		
  		
  		
  		StringBuilder finalSt=new StringBuilder();
  		ans.reverse();
  		int i=0;
  		while(st.length()>0 && i<ans.length()) {
  			
  			StringBuilder tem=new StringBuilder();
  			
  			finalSt.append(st);
  			
  			for(int j=0;j<st.length();j++) {
  				
  				if(st.charAt(j)!=ans.charAt(i))tem.append(st.charAt(j));
  			}
  			
  			i++;
  			st=tem;
  			
  			
  		}
  		
  		
  		if(ok && finalSt.toString().equals(s)) {
  			
  			out.append(s.substring(0,id+1)+" "+ans+"\n");
  			
  		}else out.append(-1+"\n");
  		
  	}
  	
  //	public void run() throws IOException {
  //		
  //		
  //		int n=sc.nextInt();
  //		int k=sc.nextInt();
  //		
  //		ArrayList<Integer> dec= inDec(n); 
  //		int ans=0;
  //		
  //		TreeSet<Integer> ts=new TreeSet<>();
  //		boolean ok=true;
  //		for(int i=0;i<dec.size();i++) {
  //			
  //			if(ok) {
  //				
  //				if(ts.contains(dec.get(i))) {
  //					
  //					ans=ans*10+dec.get(i);
  //					
  //				}
  //				else {
  //					
  //					if(k>0) {
  //						k--;
  //						ts.add(dec.get(i));
  //						ans=ans*10+dec.get(i);
  //					}
  //					else {
  //						if()
  //					}
  //					
  //				}
  //				
  //			}else {
  //				
  //				ans=ans*10+ts.first();
  //				
  //			}
  //		}
  //		
  //		
  //	}
  	
  	static ArrayList<Integer> inDec(int n) {
  		
  		ArrayList<Integer> al=new ArrayList<Integer>();
  		while(n!=0){
  			
  			al.add(n%10);
  			n/=10;
  			
  		}
  		
  		Collections.reverse(al);
  		return al;
  		
  	}
  	
  	
  	static class Reader {
          final private int BUFFER_SIZE = 1 << 16;
          private DataInputStream din;
          private byte[] buffer;
          private int bufferPointer, bytesRead;
   
          public Reader()
          {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public Reader(String file_name) throws IOException
          {
              din = new DataInputStream(
                  new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public String readLine() throws IOException
          {
              byte[] buf = new byte[64]; // line length
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n') {
                      if (cnt != 0) {
                          break;
                      }
                      else {
                          continue;
                      }
                  }
                  buf[cnt++] = (byte)c;
              }
              return new String(buf, 0, cnt);
          }
   
          public int nextInt() throws IOException
          {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          public long nextLong() throws IOException
          {
              long ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg)
                  return -ret;
              return ret;
          }
   
          public double nextDouble() throws IOException
          {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
   
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          private void fillBuffer() throws IOException
          {
              bytesRead = din.read(buffer, bufferPointer = 0,
                                   BUFFER_SIZE);
              if (bytesRead == -1)
                  buffer[0] = -1;
          }
   
          private byte read() throws IOException
          {
              if (bufferPointer == bytesRead)
                  fillBuffer();
              return buffer[bufferPointer++];
          }
   
          public void close() throws IOException
          {
              if (din == null)
                  return;
              din.close();
          }
      }
  	
  
  }
  