# Ridiculous Queries

A sequence of integers $p_{1},p_{2},…,p_{n}$ is called a permutation if the sequence contains each integer from $1$ to $n$ exactly once. For example, $[1,5,3,4,2]$ is a permutation. However, $[1,3,4]$ is not a permutation (it doesn't contain $2$ and contains $4$) and $[1,2,2,3]$ is not a permutation as well (it contains $2$ twice and doesn't contain $4$).

You are given a permutation $p_{1},p_{2},…,p_{n}$.

Let $p_{i}=k timesp[p[…[i]…]] $. For example: $p_{i}=p[i]$ and $p_{i}=p[p[i]]$.

Your task is to answer $q$ queries. For a certain number $k$, determine $1≤i≤nmax (p_{i}+i)$. In other words, determine the maximum value of $p_{i}+i$ where $1≤i≤n$.

## Input

The first line contains two integers $n$ and $q$ $(1≤n≤1000;1≤q≤10_{6})$ — the length of $p$ and the number of queries, respectively.

The next line contains $n$ integers $p_{1},p_{2},…,p_{n}$ ($1≤p_{i}≤n$) — elements of the permutation $p$. It is guaranteed that $p$ is a permutation.

Each of the next $q$ lines contains a single integer $k$ $(1≤k≤10_{9})$.

## Output

For each query, output the desired maximum.

## Examples

## Note

In the first example, we have a permutation $p=[4,1,5,2,3]$.

The first query is $k=1$, hence we must find

The second query is $k=2$. The answer is

## Scoring

($3$ points): $p=[1,2,…,n]$;

($5$ points): $q≤10$ and $k≤100$;

($7$ points): $k≤100$;

($5$ points): for each pair $1≤i,j≤n$ there exists $k$ that $p_{i}=j$;

($16$ points): $n≤20$;

($31$ points): $q≤10_{4}$;

($33$ points): no additional restrictions.