public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int tests = Integer.parseInt(in.readLine());
		
		while (tests > 0) {
			stepsToAnagram(in.readLine()); 
			tests--;
		}

	}