Brick by Brick


You are given an an infinite box of bricks where each brick has dimension a×ba \times b. By placing bricks side by side, you can construct a rectangle.

You are asked to construct a series of nn rectangles. Each rectangle must have some length-to-width ratio 1:mi1:m_i. For each rectangle, determine the minimum number of bricks you'd need to construct such a rectangle.

Input

The first line contains an integer nn, the number of rectangles you need to construct.

The second line contains two space-integers aa and bb representing the dimensions of the bricks.

The next nn lines each contain a single integer mim_i representing the ratio of the rectangle you need to construct.

Output

For each 1in1 \le i \le n, output the minimum number of bricks needed to construct a rectangle with a length-to-width ratio of 1:mi1:m_i.

Constraints

  • 1a,b10001 \le a,b \le 1000
  • 1m1091 \le m \le 10^9

Example 1

Input 1
3
2 3
1
2
5
Output 1
6
3
30
Explanation

Each brick has dimension 2×32 \times 3.

The first query 1 asks you to construct a rectangle with a length-to-width ratio of 1:11:1. We can do this with 6 bricks:

Code 1
111222
111222
333444
333444
555666
555666

where each distinct number represents a particular brick (for example, all the 1s represent the first brick). This resulting rectangle has dimension 6×66 \times 6, which is in a 1:11:1 ratio.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.