Under construction

Still being built. Things may change

Exchange

Time limit1sMemory limit128 MB

Summary
Given daily buy and sell exchange rates between marks and dollars, compute the maximum marks obtainable after N days starting from 100 marks, output as a reduced fraction.
Level

Medium5 of 10

Topics
Dynamic programming, Math, Greedy
Solved
No attempts yet

Statement

Dave has obtained, in advance, the exchange rates of the US dollar against the German mark for several upcoming days.

Dave starts with 100 marks. On each day he may, using that day's rate, convert all of his money from marks to dollars or from dollars to marks, or leave it unchanged. Write a program that decides when to buy and sell so that the amount of marks Dave holds at the end of the last day is as large as possible.

Input

The first line contains a natural number NN (1≤N≤1001 \le N \le 100), the number of future days.

Each of the next NN lines contains two natural numbers BB and SS (100≤B≤S≤1000100 \le B \le S \le 1000) separated by a space. Line i+1i+1 describes the rate on day ii.

The two numbers mean the following:

  • On that day 100 marks buy BB dollars; i.e. converting marks to dollars gives (dollars) == (marks) ×B/100\times B / 100.
  • On that day SS dollars buy 100 marks; i.e. converting dollars to marks gives (marks) == (dollars) ×100/S\times 100 / S.

Output

Print, on a single line, the maximum amount of marks Dave can hold after the last day, as an irreducible fraction p/qp/q with q≥1q \ge 1 and gcd⁡(p,q)=1\gcd(p, q) = 1. If the amount is an integer vv, print it as v/1v/1.

Examples3

  1. Example 1

    Input
    3
    393 398
    394 401
    386 386
    
    Expected output
    19700/193
    
  2. Example 2

    Input
    5
    300 300
    310 320
    320 330
    330 330
    300 320
    
    Expected output
    825/8
    
  3. Example 3

    Input
    8
    218 219
    228 231
    227 235
    205 213
    230 232
    239 239
    251 258
    205 213
    
    Expected output
    1907600/15123