const main = (stdin) => {
    const input = stdin.split("\n");
    const [ n, q ] = input[0].split(' ');
    const balls = input[1].split(' ');
      

    for(let i=2;i<=Number(q);i++) {
      const [ s, e ] = input[i].split(' ');
	  console.log(balls.slice(Number(s), Number(e)).filter((elm, index, self) => self.indexOf(elm) === index)
    }
 
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));