#include <stdio.h>

#define MAXN 100000

int a[MAXN];

int main() {
	int n,q;
	while(scanf("%d %d",&n,&q) == 2 && n) {
		for (int i=0; i<n; i++)
			scanf("%d",&a[i]);
		int i,j;
		while(q--) {
			scanf("%d %d",&i,&j);
			--i;
			int best = 0,sol;
			while(i<j) {
				int cur = a[i],cnt = 0;
				while(i < j && a[i] == cur) {
					++i;
					++cnt;
				}
				if (cnt > best) {
					best = cnt;
					sol = cur;
				}
			}
			printf("%d\n",best);
		}
	}
	return 0;
}
