CF1956A Nene's Game

题目描述

有 $n$ 个人玩一个游戏,把这 $n$ 个人分别编号为 $1$ 到 $n$。 每一轮,编号为 $ a_1, a_2, \ldots, a_k $ 的人会被踢出这个游戏,剩下的人会补齐空位并重新从 $1$ 开始编号。 当某一轮没有人被踢出时,游戏结束,剩下没有被踢出的人成为赢家。 现在请你求出最后会有多少人成为赢家。 由于 Nene 还没有确定参加游戏的具体人数,所以她会问你 $q$ 个问题,请你对 $q$ 个 $n$ 分别给出答案。

输入格式

输入共 $t$ 组数据。 每组数据的第一行输入 $k$,$q$。 第二行输入 $ a_1, a_2, \ldots, a_k $。 第三行输入 $ n_1, n_2, \ldots, n_q $。

输出格式

每组数据输出每个 $n$ 的答案,同一组数据的答案之间用空格隔开。

说明/提示

The first test case was explained in the statement. In the second test case, when $ n=1 $ , the only player stays in the game in the first round. After that, the game ends and the only player is declared as a winner.