import Foundation

func readInt() -> Int {
    Int(readLine()!)!
}
 
func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
 
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

class BIT {
    let n: Int
    var data: [Int]

    init(_ nn: Int) {
        n = (1 << Int(log2(Double(nn)).rounded(.up)))
        data = Array(repeating: 0, count: n + 1)
    }

    // [0, i)
    func query(i: Int) -> Int {
        var i = i
        var s = 0

        while i > 0 {
            s += data[i]
            i -= (i & -i)
        }

        return s
    }

    func add(i: Int, v: Int) {
        var idx = i + 1

        while idx <= n {
            data[idx] += v
            idx += (idx & -idx)
        }
    }
}

func main() {
    let (n, q) = *readInts()

    let c = readInts()

    var prev = Array(repeating: -1, count: n + 1)
    var intervals: [(Int, Int, Int)] = []

    (0..<q).forEach { i_query in 
        let (l, r) = *readInts()
        intervals.append((l - 1, i_query, r - 1))
    }

    for (i, cc) in c.enumerated() {
        if prev[cc] >= 0 {
            intervals.append((prev[cc], q, i))
        }

        prev[cc] = i
    }

    // test
    return
}

main()
