Interviews#12339

Interviews

1 second
256 megabytes
Easy

There are candidates applying to join MathModel Labs, a company that builds competitive-programming contests, stress tests, and suspiciously optimized solutions.

MathModel Labs wants to hire exactly new members.

There are interviewers. Each interviewer can attend at most interviews per day. Each interview is held with exactly one candidate and requires exactly distinct interviewers to be present.

For each test case, determine the minimum number of days needed to hire all candidates, or output if it is impossible. ATTENTION !! : This is very important , you must solve this problem via binary search on the answer , otherwise MathModel will quit coordination due to you ! , and there will be no fun and contests to be brought up in the future !!!

For example, for p=5, x=2, y=1, z=1, at least days are required. One optimal schedule is:

  1. Day :

    1. Interviewer interviews Candidate .

    2. Interviewer interviews Candidate .

  2. Day :

    1. Interviewer interviews Candidate .

    2. Interviewer interviews Candidate .

  3. Day :

    1. Interviewer interviews Candidate .

Input

The first line contains a single integer (1 \le t \le 10^4) — the number of test cases.

Each test case consists of a single line containing four integers p, x, y, z (1 \le p,x,y,z \le 10^9) — the number of candidates applying to MathModel Labs, the number of interviewers, the maximum number of interviews one interviewer can attend per day, and the number of interviewers required for a single candidate's interview.

Output

Output the minimum number of days required to interview all candidates, or print if it is impossible.

Examples

Example 1

Loading
Loading

Note

In the first test case , the process can be happen as following on just Day :

  1. Interviewers and interviews Candidate

  2. Interviewers and interviews Candidate .

  3. Interviewers and interviews Candidate .

This arrangement hold two interviewers per meeting , single candidate and a maximum of two interviews per day for an interviewer.

In the second test case, each interviewer can attend interviews with a total of candidates, so the hiring process finishes in days.

In the third test case, each interviewer can attend interviews with a total of candidate, so the hiring process finishes in days.

In the fourth test case, each interviewer can attend interviews per day, and each interview requires interviewers. One valid schedule is:

  1. Day : all interviewers interview Candidate , then all interviewers interview Candidate .

  2. Day : all interviewers interview Candidate , then all interviewers interview Candidate .

  3. Day : all interviewers interview Candidate , then all interviewers interview Candidate .

Therefore, it takes days to finish.

In the fifth test case, it can be shown that it is impossible to interview all candidates.

Scoring

  1. Subtask ( points) : (1 \le p,x,y,z \le 10)

  2. Subtask ( points) : (y=1)

  3. Subtask ( points) : No additional constraints