Football
There are players in a football team, numbered with integers from to . The skill level of player with number is described by the integer .
The players are arranged in a circle in such a way that the player with number has the player with number on their right side (for ), and for the player with number , the next player is the one with number .
Let's define the strength of a game combination, characterized by an array of integers , as follows:
initially, the ball is with the player with number ;
the players pass the ball in turns indefinitely: when performing the pass with number , the player who currently has control of the ball passes it to the player located positions to the right in the circle, where ;
the strength of the game combination is considered to be the minimum skill level among the skills of all players who had the ball at some point during the described process.
An array of integers is given. For each from to , find the strength of the game combination characterized by the array .
Input
The first line contains two integers and — the number of players and the length of the array .
The second line contains integers — the skill levels of the players.
The third line contains integers — the elements of the array .
Output
Output integers — the sought values of the strengths of game combinations.
Examples
Note
In the example of passing the ball for game combinations, it looks as follows:
Scoring
( points): ;
( points): all values of are the same;
( points): is a prime number;
( points): ;
( points): , for some integer ;
( points): ;
( points): without additional constraints.