Under construction

Still being built. Things may change

Let's Split Up!

Interview

Time limit1sMemory limit1024 MB

Summary
Split n people into two groups, each with one leader and one room, to minimize the largest danger a*k*b, and print the minimum with the assignment.
Level

Medium5 of 10

Topics
Binary search, Math, Brute force
Solved
No attempts yet

Problem

As every horror movie shows, sooner or later someone comes up with the brilliant idea of splitting up to explore a creepy, suspicious place in small groups.

This time a party of n+2n + 2 people is exploring an abandoned hut in a dark forest, and they decide to split into two groups. The party has two leaders with recklessness a1a_1 and a2a_2. Two rooms are available for the search, with suspicion levels b1b_1 and b2b_2.

Each group must have exactly one of the two leaders. If the group of the ii-th leader has kik_i people (not counting the leader) and explores room jj, the danger of that search is D=ai⋅ki⋅bjD = a_i \cdot k_i \cdot b_j.

You want to help them minimize the danger of this plan. Split the nn non-leaders into two groups (one group may be empty), and assign each group a leader and a room so that the larger of the two dangers is as small as possible.

Input

The first line contains one integer nn, the number of people not counting the two leaders (1⩽n⩽1091 \leqslant n \leqslant 10^9).

The second line contains two integers a1a_1 and a2a_2, the recklessness levels of the two leaders (1⩽a1,a2⩽1041 \leqslant a_1, a_2 \leqslant 10^4).

The third line contains two integers b1b_1 and b2b_2, the suspicion levels of the rooms (1⩽b1,b2⩽1041 \leqslant b_1, b_2 \leqslant 10^4).

Output

Print one integer, the smallest possible value of the larger of the two dangers.

On the next line, print the number of the room that the first leader's group explores and the number of people in that group (not counting the leader), separated by a space. On the last line, print the same information for the second leader's group.

If there are several answers, print any of them.

Examples1

  1. Example 1

    Input
    20
    10 30
    40 10
    
    Expected output
    1900
    2 19
    1 1