public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();
		
		int N = Integer.parseInt(str.split(" ")[0]); // length of freeway
		int T = Integer.parseInt(str.split(" ")[1]); // tests
		String []wid = sc.nextLine().split(" ");
		int []width = new int[N];
		// convert to int array
		for (int i=0;i<wid.length;i++){
			width[i]=Integer.parseInt(wid[i]);
		}
		
		// take as string value // will convert to two integers at a later stage
		String []entexits = new String[T];
		for (int i=0;i<T;i++){
			entexits[i] = sc.nextLine();
		}

		solve(width,entexits);
		sc.close();
				
		
	}