The first line contains N and Q (1≤N≤100,000, 1≤Q≤100,000).
Each of the next N lines contains an integer that is 1, 2, or 3. The number on line i is the breed ID of the i-th cow in the row.
Each of the next Q lines contains two integers a and b describing one query (1≤a≤b≤N).