Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n). For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n. Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time. Help him, find the answer for the described question for each li.

;(function() {

	var n = readline().split(' '),
		m = +n[1],
		t = {}, k = 0;
		a = readline().split(' ').map(Number);
	n = +n[0];

	for (var i = n - 1; i >= 0; i--) {
		if (!t.hasOwnProperty(a[i])) {
			t[a[i]] = true;
			k++
		}
		a[i] = k;
	}

	for (var i = 0; i < m; i++)
		print(a[+readline() - 1]);

}).call(this);

const memo1 = Array(100000);
const memo2 = Array(100000);

function check(arr) {
  var k = 0;
  for (var i = arr.length - 1; i >= 0; i--) {
    if (!memo1[arr[i]]) {
      memo1[arr[i]] = true;
      k++;
    }
    memo2[i] = k;
  }
}

function resolve(arr, ls) {
  check(arr);
  for (var i = 0; i < ls.length; i++) {
    print(memo2[ls[i] - 1]);
    // console.log(memo2[ls[i] - 1]);
  }
}

/*
const arr = '1 2 3 4 1 2 3 4 100000 99999'.split(' ');
const l = '1 2 3 4 5 6 7 8 9 10'.split(' ');

resolve(arr, l);
*/

const p = readline().split(' ');
const m = parseInt(p[1], 10);
const arr = readline().split(' ');
const ls = [];

for (var i = 0; i < m; i++) {
  var l = readline();
  ls.push(l);
}

resolve(arr, ls);

'use strict';

// const rlLib = require('readline');

// const rl = rlLib.createInterface({
//   input: process.stdin,
//   output: process.stdout
// });

// let inputs = [];
// let allCount = 12;
// let currentLine = 0;

// rl.on('line', (input) => {
//  inputs.push(input);
//  if (inputs.length >= allCount) {
//      main();

//      rl.close();
//  }
// });

// function readline() {
//  return inputs[currentLine++];
// }
// function print() {
//  console.log.apply(this, arguments);
// }

// // function main() {
// //     let count = +readline();
// //     let arr = readline().split(' ').map(function(e) {return parseInt(e, 10);});
// //     print(func(arr));
// // }

// /**
//  * @param {number} s
//  * @param {number[]} nums
//  * @return {number}
//  */
//  function main() {
    let count = +(readline().split(' ')[1]);
    let arr = readline().split(' ').map(function(e) {return parseInt(e, 10);});
    let indexes = [];
    let results = [];

    for (let i = 0; i < count; i++) {
        indexes.push(+(readline()));
    }

    let s = new Set();

    for (let i = arr.length - 1; i >= 0; i--) {
        if (s.has(arr[i])) {
            results[i] = results[i + 1] || 0;
        } else {
            s.add(arr[i]);
            results[i] = (results[i + 1] || 0) + 1;
        }
    }
    print(indexes.map(function(e) {return results[e - 1]}).join('\n'));

    // var
    //     commonSum = arr.reduce(function(s, e) {return s + e;}),
    //     sum = [arr[0], commonSum - arr[0] - arr[arr.length - 1], arr[arr.length - 1]],
    //     result = {};

    // var a = function a(sum, i, j) {
    //     if ( j - i <= 1 || result[[i, j].join('!')]) {
    //         return;
    //     }

    //     if (sum[0] === sum[1] && sum[1] === sum[2]) {
    //         result[[i, j].join('!')] = 1;
    //     }

    //     a([sum[0]+ arr[i + 1], sum[1] - arr[i + 1], sum[2]], i + 1, j);
    //     a([sum[0], sum[1] - arr[j - 1], sum[2] + arr[j - 1]], i, j - 1);
    // }

    // a(sum, 0, arr.length - 1);

    // print(Object.keys(result).length;
// };

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var m = line[1];
    var data = readline().split(' ').map(Number);
    var dp = [];
    dp[n-1] = 1;
    var all = {}
    all[data[n-1]] = true;
    for(var i=n-2;i>=0;i--){
        if(all[data[i]]){
            dp[i] = dp[i+1]
        } else {
            dp[i] = dp[i+1] + 1;
            all[data[i]] = true;
        }
    }
    for(var i=0;i<m;i++){
        print(dp[(Number(readline())-1)])
    }
}

main()

var input = readline().split(' ').map(Number), n = input[0], m = input[1];
var a = readline().split(' ').map(Number);

var mySet = new Set();
var res = [];
for (var i = a.length - 1; i >= 0; i--) {
    if (!mySet.has(a[i]))
        mySet.add(a[i]);
    res[i] = mySet.size;
}

str = '';
for (var i = 0; i < m; i++) {
    var l = readline().split(' ').map(Number);
    str += res[l-1] + '\n';
}
write(str);

var n = readline().split(/\s/gi).map(Number), m = n[1], n = n[0],
			arr = readline().split(/\s/gi),
			filterArr = [], map = {}, temp = {};

		for(var i = n - 1; i >= 0; i--)	{
			var value = arr[i];

			if(!temp[value])	{
				filterArr.push(value);
				temp[value] = 1;
			}

			map[i + 1] = filterArr.length;
		}

		for(var i = 0; i < m; i++)	{
			print(map[parseInt(readline())]);
		}

"use strict";

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

var compose = function compose() {
  for (
    var _len = arguments.length, functions = Array(_len), _key = 0;
    _key < _len;
    _key++
  ) {
    functions[_key] = arguments[_key];
  }

  return function() {
    for (
      var _len2 = arguments.length, args = Array(_len2), _key2 = 0;
      _key2 < _len2;
      _key2++
    ) {
      args[_key2] = arguments[_key2];
    }

    return functions.reduce(function(currArgs, func) {
      return func(currArgs);
    }, args);
  };
};

var lineToNumberArray = function lineToNumberArray(str) {
  return str.split(" ").map(function(num) {
    return parseInt(num, 10);
  });
};

var readNumbersLine = compose(
  readline,
  lineToNumberArray
);

var _readNumbersLine = readNumbersLine(),
  _readNumbersLine2 = _slicedToArray(_readNumbersLine, 2),
  n = _readNumbersLine2[0],
  m = _readNumbersLine2[1];

var arr = readNumbersLine().reverse();
var numbers = [];
for (var i = 0; i < m; i++) {
  var number = readNumbersLine();
  numbers.push(number);
}

var map = Object.create(null);
var arrCount = [];
var currCount = 0;

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (
    var _iterator = arr.entries()[Symbol.iterator](), _step;
    !(_iteratorNormalCompletion = (_step = _iterator.next()).done);
    _iteratorNormalCompletion = true
  ) {
    var _ref = _step.value;

    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];

    if (!map[value]) {
      currCount++;
      map[value] = 1;
    } else {
      map[value] = map[value] + 1;
    }

    arrCount[key + arr.length - 1] = currCount;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

numbers.forEach(function(pos) {
  var res = arrCount[arrCount.length - pos];
  print(res);
});

if(!this.print){
	print=console.log;
	readline=function(){
		var data = require('fs').readFileSync('./2B.in','utf8').split('\n');
		var i=0;
		return function(){
			return data[i++];
		}
	}();
}
l=readline().split(' ');
n=+l[0];
m=+l[1];
a=readline().split(' ');

var map={};
var c=0;
for(var i=n-1;i>=0;i--){
	if(map[a[i]]){
		a[i]=c;
	}else{
		map[a[i]]=true;
		a[i]=++c;
	}
}
while(m--){
	print(a[readline()-1]);
}

var input = readline().split(' ');
var n = parseInt(input[0], 10);
var m = parseInt(input[1], 10);

var numbers = readline().split(' ');

var dif = new Set();
var count = [];

for(var i = n - 1; i > -1; i--) {
    dif.add(parseInt(numbers[i]));
    count.push(dif.size);
}

for(var i = 0; i < m; i++) {
    index = readline();
    print(count[n-parseInt(index,10)]);
}

const N = 1<<17;

var n, q;
var a;

var dict;
var ans;

var token = [];

var currSize;

function initializeData() {
  a = new Array(N);
  dict = {};
  ans = new Array(N);
}

initializeData();

token = readline().split(' ');
n = parseInt(token[0]);
q = parseInt(token[1]);

token = readline().split(' ');
for(var i=0;i<n;i++) {
  a[i+1] = parseInt(token[i]);
}

currSize = 0;

for(var i=n;i>=1;i--) {
  if(dict[a[i]]==null) {
    ++currSize;
    dict[a[i]]=true;
  }

  ans[i]=currSize;
}

while(q--) {
  var currIdx = parseInt(readline());
  print(ans[currIdx]);
}

const N = 1<<17;

var n, q;
var a;

var dict;
var ans;

var token = [];

var currSize;

function initializeData() {
  a = [];// new Array(N);
  dict = {};
  ans = [];// new Array(N);
}

initializeData();

token = readline().split(' ');
n = parseInt(token[0]);
q = parseInt(token[1]);

token = readline().split(' ');
for(var i=0;i<n;i++) {
  a[i+1] = parseInt(token[i]);
}

currSize = 0;

for(var i=n;i>=1;i--) {
  if(dict[a[i]]==null) {
    ++currSize;
    dict[a[i]]=true;
  }

  ans[i]=currSize;
}

while(q--) {
  var currIdx = parseInt(readline());
  print(ans[currIdx]);
}

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[1], inputString.slice(2, inputString.length));
});

function distinctNumbers(values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var solution =[];
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        } else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum[i] = distincts;
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }
    for (let i = 0; i < nums.length; i++) {
        solution.push(perfixSum[parseInt(nums[i]) - 1])
        solution.push("\n")

    }

        console.log(solution.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            //if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

          //  else
            //    perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an
(1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, m] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {}; const data = []; let cnt = 0;
  for (let i = nums.length - 1; i >= 0; i -= 1) {
    let x = nums[i];
    if (map[x] === undefined) { cnt += 1; map[x] = true; }
    data[i] = cnt;
  }

  const answer = [];
  for (let i = 0; i < m; i += 1) {
    let x = parseInt(input[i+2]);
    answer.push(data[x-1]);
    answer.push('\n');
  }

  console.log(answer.join(""))
});

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    let valuesLen = Number(inputString[0].split(" ")[0]);
    let numLen = Number(inputString[0].split(" ")[1]);
    let values = inputString[1].split(" ");
    let nums = inputString.slice(2);
    distinctNumbers(valuesLen, numLen, values, nums);
});
function distinctNumbers(valuesLen, numLen, values, nums) {
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    var solutions = [];
    for (let i = 0; i < valuesLen; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts++;
        }
        else {
            freqArr[values[i]]++;
        }
    }
    for (let i = 0; i < valuesLen; i++) {
        perfixSum[i] = distincts;
        if (freqArr[values[i]] == 1)
            distincts--;
        else {
            freqArr[values[i]]--
        }
    }
    for (let i = 0; i < numLen; i++) {
        // console.log(perfixSum[Number(nums[i]) - 1]);
        solutions.push(perfixSum[Number(nums[i]) - 1]);
        solutions.push('\n');
    }
    console.log(solutions.join(""));
}

const memo1 = {};
const memo2 = {};

function check(arr, i) {
  if (i === -1) {
    return;
  }
  if (!memo1[arr[i]]) {
    memo1[arr[i]] = true;
  }
  memo2[i] = Object.keys(memo1).length;
  check(arr, i - 1);
}

function resolve(arr, ls) {
  check(arr, arr.length - 1);
  for (var i = 0; i < ls.length; i++) {
    print(memo2[ls[i]]);
    //console.log(memo2[ls[i] - 1]);
  }
}

/*
const arr = '1 2 3 4 1 2 3 4 100000 99999'.split(' ');
const l = '1 2 3 4 5 6 7 8 9 10'.split(' ');

resolve(arr, l);
*/

const p = readline().split(' ');
const m = parseInt(p[1], 10);
const arr = readline().split(' ');
const ls = [];

for (var i = 0; i < m; i++) {
  var l = readline();
  ls.push(l);
}

resolve(arr, ls);

var n = readline().split(/\s/gi).map(Number), m = n[1], n = n[0],
			arr = readline().split(/\s/gi),
			filterArr = [], map = {}, result = [], line = [];

		for(var i = 0; i < m; i++)	line.push(parseInt(readline()));

		for(var i = n - 1; i >= 0; i--)	{
			var value = arr[i];

			if(filterArr.indexOf(value) == -1)	{
				filterArr.push(value);
			}

			map[i + 1] = filterArr.length;

			if(line.indexOf(i + 1) > -1)	result.push(map[i + 1]);
		}

		print(result.reverse().join('\n'));

"use strict";

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

var compose = function compose() {
  for (
    var _len = arguments.length, functions = Array(_len), _key = 0;
    _key < _len;
    _key++
  ) {
    functions[_key] = arguments[_key];
  }

  return function() {
    for (
      var _len2 = arguments.length, args = Array(_len2), _key2 = 0;
      _key2 < _len2;
      _key2++
    ) {
      args[_key2] = arguments[_key2];
    }

    return functions.reduce(function(currArgs, func) {
      return func(currArgs);
    }, args);
  };
};

var lineToNumberArray = function lineToNumberArray(str) {
  return str.split(" ").map(function(num) {
    return parseInt(num, 10);
  });
};

var readNumbersLine = compose(
  readline,
  lineToNumberArray
);

var _readNumbersLine = readNumbersLine(),
  _readNumbersLine2 = _slicedToArray(_readNumbersLine, 2),
  n = _readNumbersLine2[0],
  m = _readNumbersLine2[1];

var arr = readNumbersLine();
var numbers = [];
for (var i = 0; i < m; i++) {
  var number = readNumbersLine();
  numbers.push(number);
}

var map = Object.create(null);
var count = [];

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (
    var _iterator = arr.entries()[Symbol.iterator](), _step;
    !(_iteratorNormalCompletion = (_step = _iterator.next()).done);
    _iteratorNormalCompletion = true
  ) {
    var _ref = _step.value;

    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];

    map[value] = map[value] ? map[value] + 1 : 1;
    count[key] = Object.keys(map).length;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

numbers.forEach(function(pos) {
  var res = count[count.length - 1] - (count[pos - 2] | 0);
  print(res);
});

!function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=42)}([function(t,n,r){var e=r(23)("wks"),o=r(11),i=r(1).Symbol,u="function"==typeof i;(t.exports=function(t){return e[t]||(e[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=e},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){t.exports=!r(12)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(5),o=r(15);t.exports=r(3)?function(t,n,r){return e.f(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(6),o=r(25),i=r(27),u=Object.defineProperty;n.f=r(3)?Object.defineProperty:function(t,n,r){if(e(t),n=i(n,!0),e(r),o)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(2);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n,r){var e=r(1),o=r(4),i=r(8),u=r(11)("src"),c=Function.toString,f=(""+c).split("toString");r(9).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,c){var s="function"==typeof r;s&&(i(r,"name")||o(r,"name",n)),t[n]!==r&&(s&&(i(r,u)||o(r,u,t[n]?""+t[n]:f.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:o(t,n,r):(delete t[n],o(t,n,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){var r=t.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(t,n){t.exports={}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n,r){var e=r(44),o=r(16);t.exports=function(t){return e(o(t))}},function(t,n,r){var e=r(45);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t}},function(t,n,r){"use strict";var e=r(24),o=r(30),i=r(7),u=r(4),c=r(10),f=r(46),s=r(20),a=r(52),p=r(0)("iterator"),l=!([].keys&&"next"in[].keys()),v=function(){return this};t.exports=function(t,n,r,y,h,d,_){f(r,n,y);var g,x,b,S=function(t){if(!l&&t in w)return w[t];switch(t){case"keys":case"values":return function(){return new r(this,t)}}return function(){return new r(this,t)}},m=n+" Iterator",O="values"==h,j=!1,w=t.prototype,E=w[p]||w["@@iterator"]||h&&w[h],T=E||S(h),M=h?O?S("entries"):T:void 0,P="Array"==n&&w.entries||E;if(P&&(b=a(P.call(new t)))!==Object.prototype&&b.next&&(s(b,m,!0),e||"function"==typeof b[p]||u(b,p,v)),O&&E&&"values"!==E.name&&(j=!0,T=function(){return E.call(this)}),e&&!_||!l&&!j&&w[p]||u(w,p,T),c[n]=T,c[m]=v,h)if(g={values:O?T:S("values"),keys:d?T:S("keys"),entries:M},_)for(x in g)x in w||i(w,x,g[x]);else o(o.P+o.F*(l||j),n,g);return g}},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(23)("keys"),o=r(11);t.exports=function(t){return e[t]||(e[t]=o(t))}},function(t,n,r){var e=r(5).f,o=r(8),i=r(0)("toStringTag");t.exports=function(t,n,r){t&&!o(t=r?t:t.prototype,i)&&e(t,i,{configurable:!0,value:n})}},function(t,n,r){for(var e=r(22),o=r(32),i=r(7),u=r(1),c=r(4),f=r(10),s=r(0),a=s("iterator"),p=s("toStringTag"),l=f.Array,v={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},y=o(v),h=0;h<y.length;h++){var d,_=y[h],g=v[_],x=u[_],b=x&&x.prototype;if(b&&(b[a]||c(b,a,l),b[p]||c(b,p,_),f[_]=l,g))for(d in e)b[d]||i(b,d,e[d],!0)}},function(t,n,r){"use strict";var e=r(43),o=r(28),i=r(10),u=r(13);t.exports=r(17)(Array,"Array",function(t,n){this._t=u(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):o(0,"keys"==n?r:"values"==n?t[r]:[r,t[r]])},"values"),i.Arguments=i.Array,e("keys"),e("values"),e("entries")},function(t,n,r){var e=r(9),o=r(1),i=o["__core-js_shared__"]||(o["__core-js_shared__"]={});(t.exports=function(t,n){return i[t]||(i[t]=void 0!==n?n:{})})("versions",[]).push({version:e.version,mode:r(24)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(t,n){t.exports=!1},function(t,n,r){t.exports=!r(3)&&!r(12)(function(){return 7!=Object.defineProperty(r(26)("div"),"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(2),o=r(1).document,i=e(o)&&e(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t))return t;var r,o;if(n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!e(o=r.call(t)))return o;if(!n&&"function"==typeof(r=t.toString)&&!e(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(1),o=r(9),i=r(4),u=r(7),c=r(14),f=function(t,n,r){var s,a,p,l,v=t&f.F,y=t&f.G,h=t&f.S,d=t&f.P,_=t&f.B,g=y?e:h?e[n]||(e[n]={}):(e[n]||{}).prototype,x=y?o:o[n]||(o[n]={}),b=x.prototype||(x.prototype={});for(s in y&&(r=n),r)p=((a=!v&&g&&void 0!==g[s])?g:r)[s],l=_&&a?c(p,e):d&&"function"==typeof p?c(Function.call,p):p,g&&u(g,s,p,t&f.U),x[s]!=p&&i(x,s,l),d&&b[s]!=p&&(b[s]=p)};e.core=o,f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n,r){var e=r(6),o=r(47),i=r(34),u=r(19)("IE_PROTO"),c=function(){},f=function(){var t,n=r(26)("iframe"),e=i.length;for(n.style.display="none",r(51).appendChild(n),n.src="javascript:",(t=n.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),f=t.F;e--;)delete f.prototype[i[e]];return f()};t.exports=Object.create||function(t,n){var r;return null!==t?(c.prototype=e(t),r=new c,c.prototype=null,r[u]=t):r=f(),void 0===n?r:o(r,n)}},function(t,n,r){var e=r(48),o=r(34);t.exports=Object.keys||function(t){return e(t,o)}},function(t,n,r){var e=r(18),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,r){"use strict";var e=r(54),o=r(41);t.exports=r(59)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var n=e.getEntry(o(this,"Map"),t);return n&&n.v},set:function(t,n){return e.def(o(this,"Map"),0===t?0:t,n)}},e,!0)},function(t,n,r){var e=r(7);t.exports=function(t,n,r){for(var o in n)e(t,o,n[o],r);return t}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n,r){var e=r(14),o=r(55),i=r(56),u=r(6),c=r(33),f=r(57),s={},a={};(n=t.exports=function(t,n,r,p,l){var v,y,h,d,_=l?function(){return t}:f(t),g=e(r,p,n?2:1),x=0;if("function"!=typeof _)throw TypeError(t+" is not iterable!");if(i(_)){for(v=c(t.length);v>x;x++)if((d=n?g(u(y=t[x])[0],y[1]):g(t[x]))===s||d===a)return d}else for(h=_.call(t);!(y=h.next()).done;)if((d=o(h,g,y.value,n))===s||d===a)return d}).BREAK=s,n.RETURN=a},function(t,n,r){var e=r(29),o=r(0)("toStringTag"),i="Arguments"==e(function(){return arguments}());t.exports=function(t){var n,r,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),o))?r:i?e(n):"Object"==(u=e(n))&&"function"==typeof n.callee?"Arguments":u}},function(t,n,r){var e=r(11)("meta"),o=r(2),i=r(8),u=r(5).f,c=0,f=Object.isExtensible||function(){return!0},s=!r(12)(function(){return f(Object.preventExtensions({}))}),a=function(t){u(t,e,{value:{i:"O"+ ++c,w:{}}})},p=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,e)){if(!f(t))return"F";if(!n)return"E";a(t)}return t[e].i},getWeak:function(t,n){if(!i(t,e)){if(!f(t))return!0;if(!n)return!1;a(t)}return t[e].w},onFreeze:function(t){return s&&p.NEED&&f(t)&&!i(t,e)&&a(t),t}}},function(t,n,r){var e=r(2);t.exports=function(t,n){if(!e(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n,r){"use strict";r(21),r(22),r(35),r(65);var e=new Map([[1,2],[2,2]]);print(e.get(0)),print(e.get(1))},function(t,n,r){var e=r(0)("unscopables"),o=Array.prototype;void 0==o[e]&&r(4)(o,e,{}),t.exports=function(t){o[e][t]=!0}},function(t,n,r){var e=r(29);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==e(t)?t.split(""):Object(t)}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){"use strict";var e=r(31),o=r(15),i=r(20),u={};r(4)(u,r(0)("iterator"),function(){return this}),t.exports=function(t,n,r){t.prototype=e(u,{next:o(1,r)}),i(t,n+" Iterator")}},function(t,n,r){var e=r(5),o=r(6),i=r(32);t.exports=r(3)?Object.defineProperties:function(t,n){o(t);for(var r,u=i(n),c=u.length,f=0;c>f;)e.f(t,r=u[f++],n[r]);return t}},function(t,n,r){var e=r(8),o=r(13),i=r(49)(!1),u=r(19)("IE_PROTO");t.exports=function(t,n){var r,c=o(t),f=0,s=[];for(r in c)r!=u&&e(c,r)&&s.push(r);for(;n.length>f;)e(c,r=n[f++])&&(~i(s,r)||s.push(r));return s}},function(t,n,r){var e=r(13),o=r(33),i=r(50);t.exports=function(t){return function(n,r,u){var c,f=e(n),s=o(f.length),a=i(u,s);if(t&&r!=r){for(;s>a;)if((c=f[a++])!=c)return!0}else for(;s>a;a++)if((t||a in f)&&f[a]===r)return t||a||0;return!t&&-1}}},function(t,n,r){var e=r(18),o=Math.max,i=Math.min;t.exports=function(t,n){return(t=e(t))<0?o(t+n,0):i(t,n)}},function(t,n,r){var e=r(1).document;t.exports=e&&e.documentElement},function(t,n,r){var e=r(8),o=r(53),i=r(19)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),e(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n,r){var e=r(16);t.exports=function(t){return Object(e(t))}},function(t,n,r){"use strict";var e=r(5).f,o=r(31),i=r(36),u=r(14),c=r(37),f=r(38),s=r(17),a=r(28),p=r(58),l=r(3),v=r(40).fastKey,y=r(41),h=l?"_s":"size",d=function(t,n){var r,e=v(n);if("F"!==e)return t._i[e];for(r=t._f;r;r=r.n)if(r.k==n)return r};t.exports={getConstructor:function(t,n,r,s){var a=t(function(t,e){c(t,a,n,"_i"),t._t=n,t._i=o(null),t._f=void 0,t._l=void 0,t[h]=0,void 0!=e&&f(e,r,t[s],t)});return i(a.prototype,{clear:function(){for(var t=y(this,n),r=t._i,e=t._f;e;e=e.n)e.r=!0,e.p&&(e.p=e.p.n=void 0),delete r[e.i];t._f=t._l=void 0,t[h]=0},delete:function(t){var r=y(this,n),e=d(r,t);if(e){var o=e.n,i=e.p;delete r._i[e.i],e.r=!0,i&&(i.n=o),o&&(o.p=i),r._f==e&&(r._f=o),r._l==e&&(r._l=i),r[h]--}return!!e},forEach:function(t){y(this,n);for(var r,e=u(t,arguments.length>1?arguments[1]:void 0,3);r=r?r.n:this._f;)for(e(r.v,r.k,this);r&&r.r;)r=r.p},has:function(t){return!!d(y(this,n),t)}}),l&&e(a.prototype,"size",{get:function(){return y(this,n)[h]}}),a},def:function(t,n,r){var e,o,i=d(t,n);return i?i.v=r:(t._l=i={i:o=v(n,!0),k:n,v:r,p:e=t._l,n:void 0,r:!1},t._f||(t._f=i),e&&(e.n=i),t[h]++,"F"!==o&&(t._i[o]=i)),t},getEntry:d,setStrong:function(t,n,r){s(t,n,function(t,r){this._t=y(t,n),this._k=r,this._l=void 0},function(){for(var t=this._k,n=this._l;n&&n.r;)n=n.p;return this._t&&(this._l=n=n?n.n:this._t._f)?a(0,"keys"==t?n.k:"values"==t?n.v:[n.k,n.v]):(this._t=void 0,a(1))},r?"entries":"values",!r,!0),p(n)}}},function(t,n,r){var e=r(6);t.exports=function(t,n,r,o){try{return o?n(e(r)[0],r[1]):n(r)}catch(n){var i=t.return;throw void 0!==i&&e(i.call(t)),n}}},function(t,n,r){var e=r(10),o=r(0)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(e.Array===t||i[o]===t)}},function(t,n,r){var e=r(39),o=r(0)("iterator"),i=r(10);t.exports=r(9).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||i[e(t)]}},function(t,n,r){"use strict";var e=r(1),o=r(5),i=r(3),u=r(0)("species");t.exports=function(t){var n=e[t];i&&n&&!n[u]&&o.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n,r){"use strict";var e=r(1),o=r(30),i=r(7),u=r(36),c=r(40),f=r(38),s=r(37),a=r(2),p=r(12),l=r(60),v=r(20),y=r(61);t.exports=function(t,n,r,h,d,_){var g=e[t],x=g,b=d?"set":"add",S=x&&x.prototype,m={},O=function(t){var n=S[t];i(S,t,"delete"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"has"==t?function(t){return!(_&&!a(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return _&&!a(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,r){return n.call(this,0===t?0:t,r),this})};if("function"==typeof x&&(_||S.forEach&&!p(function(){(new x).entries().next()}))){var j=new x,w=j[b](_?{}:-0,1)!=j,E=p(function(){j.has(1)}),T=l(function(t){new x(t)}),M=!_&&p(function(){for(var t=new x,n=5;n--;)t[b](n,n);return!t.has(-0)});T||((x=n(function(n,r){s(n,x,t);var e=y(new g,n,x);return void 0!=r&&f(r,d,e[b],e),e})).prototype=S,S.constructor=x),(E||M)&&(O("delete"),O("has"),d&&O("get")),(M||w)&&O(b),_&&S.clear&&delete S.clear}else x=h.getConstructor(n,t,d,b),u(x.prototype,r),c.NEED=!0;return v(x,t),m[t]=x,o(o.G+o.W+o.F*(x!=g),m),_||h.setStrong(x,t,d),x}},function(t,n,r){var e=r(0)("iterator"),o=!1;try{var i=[7][e]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var i=[7],u=i[e]();u.next=function(){return{done:r=!0}},i[e]=function(){return u},t(i)}catch(t){}return r}},function(t,n,r){var e=r(2),o=r(62).set;t.exports=function(t,n,r){var i,u=n.constructor;return u!==r&&"function"==typeof u&&(i=u.prototype)!==r.prototype&&e(i)&&o&&o(t,i),t}},function(t,n,r){var e=r(2),o=r(6),i=function(t,n){if(o(t),!e(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,e){try{(e=r(14)(Function.call,r(63).f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,r){return i(t,r),n?t.__proto__=r:e(t,r),t}}({},!1):void 0),check:i}},function(t,n,r){var e=r(64),o=r(15),i=r(13),u=r(27),c=r(8),f=r(25),s=Object.getOwnPropertyDescriptor;n.f=r(3)?s:function(t,n){if(t=i(t),n=u(n,!0),f)try{return s(t,n)}catch(t){}if(c(t,n))return o(!e.f.call(t,n),t[n])}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,r){r(66),r(67),r(21),r(35),t.exports=r(9).Map},function(t,n,r){"use strict";var e=r(39),o={};o[r(0)("toStringTag")]="z",o+""!="[object z]"&&r(7)(Object.prototype,"toString",function(){return"[object "+e(this)+"]"},!0)},function(t,n,r){"use strict";var e=r(68)(!0);r(17)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,r=this._i;return r>=n.length?{value:void 0,done:!0}:(t=e(n,r),this._i+=t.length,{value:t,done:!1})})},function(t,n,r){var e=r(18),o=r(16);t.exports=function(t){return function(n,r){var i,u,c=String(o(n)),f=e(r),s=c.length;return f<0||f>=s?t?"":void 0:(i=c.charCodeAt(f))<55296||i>56319||f+1===s||(u=c.charCodeAt(f+1))<56320||u>57343?t?c.charAt(f):i:t?c.slice(f,f+2):u-56320+(i-55296<<10)+65536}}}]);

"use strict";

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

var compose = function compose() {
  for (
    var _len = arguments.length, functions = Array(_len), _key = 0;
    _key < _len;
    _key++
  ) {
    functions[_key] = arguments[_key];
  }

  return function() {
    for (
      var _len2 = arguments.length, args = Array(_len2), _key2 = 0;
      _key2 < _len2;
      _key2++
    ) {
      args[_key2] = arguments[_key2];
    }

    return functions.reduce(function(currArgs, func) {
      return func(currArgs);
    }, args);
  };
};

var lineToNumberArray = function lineToNumberArray(str) {
  return str.split(" ").map(function(num) {
    return parseInt(num, 10);
  });
};

var readNumbersLine = compose(
  readline,
  lineToNumberArray
);

var _readNumbersLine = readNumbersLine(),
  _readNumbersLine2 = _slicedToArray(_readNumbersLine, 2),
  n = _readNumbersLine2[0],
  m = _readNumbersLine2[1];

var arr = readNumbersLine();
var numbers = [];
for (var i = 0; i < m; i++) {
  var number = readNumbersLine();
  numbers.push(number);
}

var map = Object.create(null);
var count = [];

var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;

try {
  for (
    var _iterator = arr.entries()[Symbol.iterator](), _step;
    !(_iteratorNormalCompletion = (_step = _iterator.next()).done);
    _iteratorNormalCompletion = true
  ) {
    var _ref = _step.value;

    var _ref2 = _slicedToArray(_ref, 2),
      key = _ref2[0],
      value = _ref2[1];

    map[value] = map[value] ? map[value] + 1 : 1;
    count[key] = Object.keys(map).length;
  }
} catch (err) {
  _didIteratorError = true;
  _iteratorError = err;
} finally {
  try {
    if (!_iteratorNormalCompletion && _iterator.return) {
      _iterator.return();
    }
  } finally {
    if (_didIteratorError) {
      throw _iteratorError;
    }
  }
}

numbers.forEach(function(pos) {
  var posOutside = pos - 2;
  var res = count[count.length - 1] - (posOutside < 0 ? 0 : count[posOutside]);
  print(res);
});

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    console.log(perfixSumForDistinct);

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[0], inputString[1], inputString.slice(2, inputString.length));
});
function distinctNumbers(nm, values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        }
        else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum.push( distincts);
        perfixSum.push( "\n");
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }
        console.log(perfixSum.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    if (lenthOfInput == 81220) {
        console.log(input);
        console.log(locations);
    }
    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] + 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[index]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

 'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[1], inputString.slice(2, inputString.length));
});

function distinctNumbers(values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        } else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum[i] = distincts;
        perfixSum.push("\n")
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }
        console.log(perfixSum.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    // console.log("input ",inputString.slice(2,inputString.length));
    distinctNumbers(inputString[0], inputString[1], inputString.slice(2, inputString.length));
});
function distinctNumbers(nm, values, nums) {
    values = values.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var sol = []
    var distincts = 0;
    for (let i = 0; i < values.length; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts += 1;
        }
        else {
            freqArr[values[i]] += 1;
        }
    }
    for (let i = 0; i < values.length; i++) {
        perfixSum.push( distincts);
        perfixSum.push( "\n");
        if (freqArr[values[i]] == 1)
            distincts -= 1;
        else {
            freqArr[values[i]] -= 1
        }
    }

    for(let i = 0 ; i <nums.length ; i++){
       sol.push(perfixSum[Number(nums[i] - 1 )])
       sol.push("\n")
    }

        console.log(perfixSum.join(""));

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')'

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    console.log(input);
    console.log(locations);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    if (lenthOfInput == 81220) {
        console.log(locations);
    }
    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

/**
 *
 *
Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing,
 he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n).
  For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n.
  Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time.
Help him, find the answer for the described question for each li.

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output
Print m lines — on the i-th line print the answer to the number li.

Input

10 10
1 2 3 4 1 2 3 4 100000 99999
[ 1, 2, 3, 4, 4, 4, 4, 4, 5, 6 ]
1,
2
3
4
5
6
7
8
9
10

Output

6
6
6
6
6
5
4
3
2
1
 */

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    let lenthOfInput = Number(inputString[0].split(" ")[0]);
    let lengthOfLocations = Number(inputString[0].split(" ")[1]);
    let input = inputString[1].split(" ");
    let locations = inputString.slice(2, 12);

    solution(lenthOfInput, lengthOfLocations, input, locations);
});

function solution(lenthOfInput, lengthOfLocations, input, locations) {

    let solutionArray = [];
    let frequencyMap = {};
    let perfixSumForDistinct = [];

    for (let index = lenthOfInput - 1; index > -1; index--) {

        if (!frequencyMap[input[index]]) {

            if (index)
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] ? perfixSumForDistinct[index + 1] + 1 : 1

            else
                perfixSumForDistinct[index] = perfixSumForDistinct[index + 1] + 1
        }

        if (frequencyMap[input[index]]) {
            perfixSumForDistinct[index] = perfixSumForDistinct[index + 1]
        }

        frequencyMap[input[index]] = 1;
    }

    for (let index = 0; index < lengthOfLocations; index++) {
        let solution = perfixSumForDistinct[locations[index] - 1]
        solutionArray.push(solution);
        solutionArray.push("\n")
    }

    console.log(solutionArray.join(""));

}

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, m] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {}; const data = []; let cnt = 0;
  for (let i = nums.length - 1; i >= 0; i -= 1) {
    let x = nums[i];
    if (map[x] === undefined) { cnt += 1; map[x] = true; }
    data[i] = cnt;
  }

  const answer = [];
  for (let i = 0; i < m; i += 1) {
    let x = parseInt(input[i+2]);
    answer.push(data[x]);
  }

  console.log(answer.join("\n"))
});

const input = [];

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, m] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {}; const data = []; let cnt = 0;
  for (let i = nums.length - 1; i >= 0; i -= 1) {
    let x = nums[i];
    if (map[x] === undefined) { cnt += 1; map[x] = true; }
    data[i] = cnt;
  }

  const answer = [];
  for (let i = 0; i < m; i += 1) {
    let x = parseInt(input[i+2]);
    answer.push(data[x]);
    if (i + 1 < m)
      answer.push('\n');
  }

  console.log(answer.join(""))
});

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    for(let i = 0; i <nums.length;i++){
        var index =  parseInt(nums[i]) -1;
        console.log(perfixSum[index]);

    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    values = values.split(" ");
    nums = nums.split(" ");
    nm = nm.split(" ");
    var  numsLen = nm[1];
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    for(let i = 0; i <numsLen;i++){
        var index =  parseInt(nums[i]) -1;
        console.log(perfixSum[index]);

    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    for(let i = 0; i <nums.length;i++){
        var index =  nums[i] -1;
        console.log(perfixSum[index]);

    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('8 3', '8 6 4 3 4 2 4 8', '6 4 2')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    var lastCount = 0;
    for (let i = 0; i < perfixSum.length; i++) {
        if (lastCount == perfixSum[i]) {
            console.log(distincts);
            distincts = distincts - 1;
        }
        else
            console.log(distincts);
        lastCount = perfixSum[i];
    }
}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    let valuesLen = Number(inputString[0].split(" ")[0]);
    let numLen = Number(inputString[0].split(" ")[1]);
    let values = inputString[1].split(" ");
    let nums = inputString.slice(2);
    distinctNumbers(valuesLen, numLen, values, nums);
});
function distinctNumbers(valuesLen, numLen, values, nums) {
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    for (let i = 0; i < valuesLen; i++) {
        if (!freqArr[values[i]]) {
            freqArr[values[i]] = 1;
            distincts++;
        }
        else {
            freqArr[values[i]]++;
        }
    }
    for (let i = 0; i < valuesLen; i++) {
        perfixSum[i] = distincts;
        if (freqArr[values[i]] == 1)
            distincts--;
        else {
            freqArr[values[i]]--
        }
        if(nums[i])
        console.log(perfixSum[Number(nums[i]) - 1]);

    }
    // for (let i = 0; i < numLen; i++) {
    // }
}

'use strict';

let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    distinctNumbers(inputString[0], inputString[1],inputString[2]);
});
function distinctNumbers(nm, values, nums) {
    var values = values.split(" ");
    var nums = nums.split(" ");
    var freqArr = {};
    var perfixSum = [];
    var distincts = 0;
    // for(let i = 0; i < values.length; i++)
    for (let i = 0; i < values.length; i++) {
        var val = values[i];
        if (!freqArr[val]) {
            freqArr[val] = 1;
            distincts += 1;
            // perfixSum[i] = i == 0 ? 1 : perfixSum[i - 1] + 1;
        }
        else {
            // perfixSum[i] = i > 0 ? perfixSum[i - 1] : 1;
            freqArr[val] += 1;
        }
    }
    for(let i = 0; i < values.length; i++){
        var val = values[i];
        perfixSum[i] = distincts;
        console.log(distincts);

        if(freqArr[val] == 1)
        distincts -=1;
        else{
            freqArr[val] -=1
        }
    }
    // console.log("perf ",perfixSum);

}
// distinctNumbers('10 10', '1 2 3 4 1 2 3 4 100000 99999', '1 2 3 4 5 6 7 8 9 10')


A picture can be represented as an $$$n\times m$$$ grid ($$$n$$$ rows and $$$m$$$ columns) so that each of the $$$n \cdot m$$$ cells is colored with one color. You have $$$k$$$ pigments of different colors. You have a limited amount of each pigment, more precisely you can color at most $$$a_i$$$ cells with the $$$i$$$-th pigment.A picture is considered beautiful if each cell has at least $$$3$$$ toroidal neighbors with the same color as itself.Two cells are considered toroidal neighbors if they toroidally share an edge. In other words, for some integers $$$1 \leq x_1,x_2 \leq n$$$ and $$$1 \leq y_1,y_2 \leq m$$$, the cell in the $$$x_1$$$-th row and $$$y_1$$$-th column is a toroidal neighbor of the cell in the $$$x_2$$$-th row and $$$y_2$$$-th column if one of following two conditions holds:  $$$x_1-x_2 \equiv \pm1 \pmod{n}$$$ and $$$y_1=y_2$$$, or  $$$y_1-y_2 \equiv \pm1 \pmod{m}$$$ and $$$x_1=x_2$$$. Notice that each cell has exactly $$$4$$$ toroidal neighbors. For example, if $$$n=3$$$ and $$$m=4$$$, the toroidal neighbors of the cell $$$(1, 2)$$$ (the cell on the first row and second column) are: $$$(3, 2)$$$, $$$(2, 2)$$$, $$$(1, 3)$$$, $$$(1, 1)$$$. They are shown in gray on the image below:  The gray cells show toroidal neighbors of $$$(1, 2)$$$. Is it possible to color all cells with the pigments provided and create a beautiful picture?

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^4$$$). The description of the test cases follows. The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$3 \leq n,m \leq 10^9$$$, $$$1 \leq k \leq 10^5$$$) — the number of rows and columns of the picture and the number of pigments. The next line contains $$$k$$$ integers $$$a_1,a_2,\dots, a_k$$$ ($$$1 \leq a_i \leq 10^9$$$) — $$$a_i$$$ is the maximum number of cells that can be colored with the $$$i$$$-th pigment. It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print "Yes" (without quotes) if it is possible to color a beautiful picture. Otherwise, print "No" (without quotes).

NoteIn the first test case, one possible solution is as follows:  In the third test case, we can color all cells with pigment $$$1$$$.

var a = [];

    function check(n, m, k) {
        var index = 0;
        var limit = Math.min(k, Math.floor(n/2));
        var total = n;
        var record = [];
        while (total > 0 && index < limit) {
            if (total == 1) {
                if (record[0] > 2) {
                    record[0]--;
                    total++;
                }
            }
            var rows = Math.floor(a[index] / m);
            total -= rows;
            record.push(rows);
            index++;
            if (rows < 2) {
                break;
            }
        }
        return total <= 0;
    }

    var tests = parseInt(readline());
    for (var t=0; t < tests; t++) {
        var nmk = readline().split(' ').map(x=>parseInt(x));
        var n = nmk[0];
        var m = nmk[1];
        var k = nmk[2];
        a = readline().split(' ').map(x=>parseInt(x));
        a.sort((x, y) => y-x);
        if (check(n, m, k) || check(m, n, k)) {
            print('Yes');
        } else {
            print('No');
        }
    }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

function readNumbersLine() {
    return readline().split(" ").map(el => +el);
}

function solve() {
    let [n, m, k] = readNumbersLine()

    let A = readNumbersLine()
    let startSum = n * m

    if (n > m) {
        [n, m] = [m, n]
    }

    A.sort((a, b) => a - b)
    let [n2, m2] = [n, m]

    for (let i = 0; i < A.length; i++) {
        if (Math.floor(A[i] / n) >= 2) {
            m = m - Math.floor(A[i] / n)
        }
        if (m === 1) {
            if (Math.floor(A[i] / n) > 2) {
                m += 1
            } else {
                m += 2
            }
        }
        if (m <= 0) {
            console.log("YES")
            return
        }
    }

    for (let i = 0; i < A.length; i++) {
        if (Math.floor(A[i] / m2) >= 2) {
            n2 = n2 - Math.floor(A[i] / m2)
        }
        if (n2 === 1) {
            if (Math.floor(A[i] / m2) > 2) {
                n2 += 1
            } else {
                n2 += 2
            }
        }
        if (n2 <= 0) {
            console.log("YES")
            return
        }
    }

    console.log("NO");
    return;

}

function main() {
    let k = +readline()
    for (let i = 0; i < k; i++) {
        solve();
    }

}