eolymp
bolt
Try our new interface for solving problems
Problems

Falling Portals

Falling Portals

There are n worlds, each with a portal. Initially, world i (for 1in) is at x-coordinate i, and y-coordinate Ai (1Ai109). There is also a cow on each world. At time 0, all y-coordinates are distinct and the worlds start falling: world i moves continuously in the negative y direction at a speed of i units per second.

At any time when two worlds are at the same y-coordinate (possibly a fractional time), the portals "align", meaning that a cow on one of the worlds can choose to travel instantaneously to the other world.

For each i, the cow on world i wants to travel to world Qi (Qii). Help each cow determine how long her journey will take, if she travels optimally.

Each query output should be a fraction a / b where a and b are positive and relatively prime integers, or −1 if it the journey is impossible.

Input

The first line contains a single integer n (2n2 * 105). The next line contains n space-separated integers A1, A2, ..., An. The next line contains n integers Q1, Q2, ..., Qn.

Output

Print n lines, the i-th of which contains the journey length for cow i.

Time limit 1 second
Memory limit 128 MiB
Input example #1
4
3 5 10 2
3 3 2 1
Output example #1
7/2
7/2
5/1
-1
Source 2020 USACO January Platinum