import java.util.*; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author cteam24 */ public class unique { public static void main(String[] args) { Scanner s = new Scanner(System.in); for(;;) { int size = s.nextInt(); int qs = s.nextInt(); if( size == 0 && qs == 0 ) { break; } int[] k = new int[size]; for( int i = 0; i < size; i++ ) { k[i] = s.nextInt(); } for( int j = 0; j < qs; j++ ) { Set set = new HashSet(); int from = s.nextInt() - 1; int to = s.nextInt() - 1; boolean first = true; for( int i = from; i <= to; i++ ) { int n = k[i]; if( set.contains( n ) ) { System.out.println( n ); first = false; break; } set.add( n ); } if( first ) System.out.println("OK"); } } } }