For this Question: Given N strings and Q queries, for each query you will be given a string, your task is to print all the anagrams of the string from the given N strings. If no anagrams exist then print -1.

Note:- Given string may contain duplicated strings you should print it as many times as it occurs.First line of input contains a single integer N, second line of input contains N space separated strings. Third line of input contains a single integer Q, next Q line contains a single string each.

Constraints:-
1 < = N < = 1000
1 < = |String| < = 10
1 < = Q < = 100000

Note:-String will only contain lower case english lettersFor each query in a new line print the anagrams in lexicographical order separated by spaces.Sample Input:-
6
cat tea pet tac act eat
4
cat
tca
eee
tea

Sample Output:-
act cat tac
act cat tac
-1
eat tea, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException {


		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		HashMap<String, List<String> > hs=new HashMap<>();
		int n=Integer.parseInt(br.readLine());
		String st[]=br.readLine().split(" ");
		for(int i=0;i<n;i++){
			String temp=st[i];
			char ch[]=temp.toCharArray();
			Arrays.sort(ch);
			String temp1=new String(ch);
			if(hs.containsKey(temp1)){
				hs.get(temp1).add(temp);
			}
			else{
				List<String> ValueList = new ArrayList<>();
				ValueList.add(temp);
				hs.put(temp1,ValueList);
			}
		}
		int q=Integer.parseInt(br.readLine());
		for(int i=0;i<q;i++){
			String check=br.readLine();
			char temp[]=check.toCharArray();
			Arrays.sort(temp);
			check=new String(temp);
			if(hs.containsKey(check)){
				List<String> li=hs.get(check);
				Collections.sort(li);
				int x=li.size();
				for(int j=0;j<x;j++){
					System.out.print(li.get(j)+" ");
				}
				System.out.println();
			}
			else{
				System.out.println(-1);
			}
		}
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?