import java.io.*; // for handling input/output import java.util.*; // contains Collections framework // don't change the name of this class // you can add inner classes if needed class Main { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t>0) { int[] freqCounter = new int[26]; String str = scan.next(); for(int i = 0; i < str.length(); i++) { freqCounter[str.charAt(i) - 'a']++; } boolean flag = true; for(int i = 0; i < str.length(); i++) { if(freqCounter[str.charAt(i)-'a'] > 1){ System.out.println(str.charAt(i)); flag = false; break; } } if(flag) { System.out.println(-1); } t--; } } }