#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<cmath>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)

const int maxn = 1000005;

map<int,int> pos;
int gen[maxn];
int ww[maxn];
//int gen2[maxn];
//set<int> last;

bool go(int g) {
	int m,q;
	scanf("%d %d", &m,&q);
	if(m == 0 ) return false;
	pos.clear();
	REP(i,m)
		ww[i]=-1;
	REP(i,m) {
		int a;
		scanf("%d", &a);
		if(pos.find(a) != pos.end())  
		{
			//last.erase(pos[a]);
			//cerr<<" - " << i << " - "<< a << " : " << pos[a] << endl;
			ww[i] = pos[a];
		}
		
		
		pos[a] = i;
		//last.insert(a);
		
		
	}
	//REP(i,m) printf("%d\n", ww[i]);
	int first = -1;
	
	REP(i,m) 
	{
		first = max(first, ww[i]);
		
		ww[i] = first;
		//cerr<<"f"<<first<<endl;
	}
	//REP(i,m) printf(" -- %d\n", ww[i]);

	REP(i,q) 
	{
		int a,b;
		scanf("%d %d", &a,&b);
		a--; b--;
		//cerr << " cerr " << a << " :: " << b << endl;
		if(ww[b] >= a) 
		{
			printf("%d\n", ww[b] + 1);
		}
		else 
			printf("OK\n");
	}

	printf("\n");
	return true;
}

int main() {

	int g=2;
	while(go(g++)) {
	}
	return 0;
}


