public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cases = Integer.parseInt(sc.nextLine());
		for(int i = 0; i<cases; i++) {
			System.out.println("Test case #" + (i+1));
			List<Integer> s = new ArrayList<Integer>();
			StringTokenizer st = new StringTokenizer(sc.nextLine());
			int lSeq = Integer.parseInt(st.nextToken());
			int nCases = Integer.parseInt(st.nextToken());
			st = new StringTokenizer(sc.nextLine());
			for(int j = 0; j<lSeq; j++) {
				s.add(Integer.parseInt(st.nextToken()));
			}
			
			for(int j = 0; j<nCases; j++) {
				st = new StringTokenizer(sc.nextLine());
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				int last = s.get(a-1);
				int count = 1;
				int max = 1;
				for(int k = a; k<b; k++) {
					int q = s.get(k);
					if(q == last) count++;
					else {
						if(count > max) max = count;
						last = q;
						count = 1;
					}
				}
				if(count > max) max = count;
				System.out.println(max);
			}
		}
		sc.close();
	}