Unique Encryption Keys
The security of many ciphers strongly depends on the fact that the keys are unique and never reused. This may be vitally important, since a relatively strong cipher may be broken if the same key is used to encrypt several different messages.
In this problem, we will try to detect repeating (duplicate) usage of keys. Given a sequence of keys used to encrypt messages, your task is to determine what keys have been used repeatedly in some specified period.
Input
Contains several cipher descriptions. Each description starts with one line containing two integer numbers m and q separated by a space. m (1 ≤ m ≤ 10^6
) is the number of encrypted messages, q (0 ≤ q ≤ 10^6
) is the number of queries.
Each of the following m lines contains one number k[i]
(0 ≤ k[i]
≤ 2^30
) specifying the identifier of a key used to encrypt the i-th message. The next q lines then contain one query each. Each query is specified by two integer numbers b[j]
and e[j]
(1 ≤ b[j]
≤ e[j]
≤ m), giving the interval of messages we want to check.
There is one empty line after each description. The input is terminated by a line containing two zeros in place of the numbers m and q.
Output
For each query, print one line of output. The line should contain the string "OK" if all keys used to encrypt messages between b[j]
and e[j]
(inclusive) are mutually different (that means, they have different identifiers). If some of the keys have been used repeatedly, print one identifier of any such key.
Print one empty line after each cipher description.