B. Routine Problem

problem_index: B

time_limit: 1 second

memory_limit: 256 megabytes

note:
Sample 1. Manao's monitor has a square screen. The movie has 3:2 horizontal to vertical length ratio. Obviously, the movie occupies most of the screen if the width of the picture coincides with the width of the screen. In this case, only 2/3 of the monitor will project the movie in the horizontal dimension: ![image](images/cf_337_B/1.png)
Sample 2. This time the monitor's width is 4/3 times larger than its height and the movie's frame is square. In this case, the picture must take up the whole monitor in the vertical dimension and only 3/4 in the horizontal dimension: ![image](images/cf_337_B/2.png)

solutions: ["import random\nfrom fractions import gcd\n\ndef average(x):\n\treturn sum(x) / len(x)\n\ndef shuffled(a):\n\ta = list(a)\n\trandom.shuffle(a)\n\treturn a\n\ndef read_ints():\n\treturn [int(i) for i in input().split()]\n\ndef decrease(a):\n\treturn [i - 1 for i in a]\n\ndef main():\n\t(a, b, c, d) = read_ints()\n\tif a / b < c / d:\n\t\t(a, b, c, d) = (b, a, d, c)\n\t(p, q) = (a * d - c * b, b * d)\n\t(s, t) = (p, a * d)\n\tprint(s // gcd(s, t), t // gcd(s, t), sep='/')\nmain()\n", "from math import gcd\n(a, b, c, d) = map(int, input().split())\n(p, q) = (-1, -1)\nif d * a <= c * b:\n\tp = b * c - d * a\n\tq = b * c\nelse:\n\tp = a * d - b * c\n\tq = a * d\nprint('%d/%d' % (p / gcd(p, q), q / gcd(p, q)))\n", "from fractions import Fraction as f\nr = list(map(int, input().split()))\n(a, b) = (r[0], r[1])\n(c, d) = (r[2], r[3])\nans = min(abs(f(a * b - c * d * f(a, c) ** 2, a * b)), abs(f(a * b - c * d * f(b, d) ** 2, a * b)))\nif ans == 0:\n\tprint('0/1')\nelse:\n\tprint(ans)\n", "def nok(first, second):\n\tmx = max(first, second)\n\tfinal = mx\n\twhile final % first != 0 or final % second != 0:\n\t\tfinal += mx\n\treturn final\n\ndef nod(first, second):\n\t(_mx, _mn) = (max(first, second), min(first, second))\n\twhile _mx % _mn != 0:\n\t\t(_mx, _mn) = (_mn, _mx % _mn)\n\treturn _mn\nratios = [int(i) for i in input().split()]\nif ratios[0] == ratios[1] and ratios[2] == ratios[3]:\n\tprint('0/1')\n\tquit()\nnk = nok(ratios[0], ratios[2])\nratios[1] *= nk // ratios[0]\nratios[0] *= nk // ratios[0]\nratios[3] *= nk // ratios[2]\nratios[2] *= nk // ratios[2]\n(left, right) = (max(ratios[1], ratios[3]) - min(ratios[1], ratios[3]), max(ratios[1], ratios[3]))\nprint(str(left // nod(left, right)) + '/' + str(right // nod(left, right)))\n", "import sys\ninf = float('inf')\nfrom math import ceil, floor, log, sqrt, factorial, pi, gcd\n\ndef get_array():\n\treturn list(map(int, sys.stdin.readline().strip().split()))\n\ndef get_ints():\n\treturn map(int, sys.stdin.readline().strip().split())\n\ndef input():\n\treturn sys.stdin.readline().strip()\n(a, b, c, d) = get_ints()\nif a * d < c * b:\n\t(a, b) = (b, a)\n\t(c, d) = (d, c)\na *= d\nc *= b\np = a - c\nq = a\ng = gcd(p, q)\np //= g\nq //= g\nprint(f'{p}/{q}')\n", "import math\n(n, k, l, m) = map(int, input().split())\nk = k * l\nm = m * n\na = abs(k - m)\nb = max(k, m)\nx = math.gcd(a, b)\na //= x\nb //= x\nprint(str(a) + '/' + str(b))\n", "MOD = 1000000007\nii = lambda : int(input())\nsi = lambda : input()\ndgl = lambda : list(map(int, input()))\nf = lambda : map(int, input().split())\nil = lambda : list(map(int, input().split()))\nls = lambda : list(input())\nfrom math import *\n(a, b, c, d) = f()\nif a / c < b / d:\n\tx = a * b * c * c - a * a * c * d\n\ty = a * b * c * c\n\tg = gcd(x, y)\n\tprint(str(x // g) + '/' + str(y // g))\nelif a / c > b / d:\n\tx = a * b * d * d - c * b * d * b\n\ty = a * b * d * d\n\tg = gcd(x, y)\n\tprint(str(x // g) + '/' + str(y // g))\nelse:\n\tprint('0/1')\n", "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n\ndef main():\n\t(a, b, c, d) = map(int, input().split())\n\tif d * a <= b * c:\n\t\tnom = a * d\n\t\tdem = b * c\n\t\tg = gcd(nom, dem)\n\t\tnom = nom // g\n\t\tdem = dem // g\n\t\tans = (dem - nom, dem)\n\t\tif ans[0] != 0:\n\t\t\tprint('{:d}/{:d}'.format(*ans))\n\t\telse:\n\t\t\tprint('0/1')\n\telse:\n\t\tnom = b * c\n\t\tdem = a * d\n\t\tg = gcd(nom, dem)\n\t\tnom = nom // g\n\t\tdem = dem // g\n\t\tans = (dem - nom, dem)\n\t\tif ans[0] != 0:\n\t\t\tprint('{:d}/{:d}'.format(*ans))\n\t\telse:\n\t\t\tprint('0/1')\nmain()\n", "from math import gcd\n\ndef take_input(s):\n\tif s == 1:\n\t\treturn int(input())\n\treturn map(int, input().split())\n\ndef redc(a, b):\n\tc = gcd(a, b)\n\treturn (a // c, b // c)\n(a, b, c, d) = take_input(4)\n(a, b) = redc(a, b)\n(c, d) = redc(c, d)\nif c != d:\n\ttake = max(c, d)\n\tif take == c:\n\t\titake = d\n\t\tover = a\n\t\tiover = b\n\telse:\n\t\titake = c\n\t\tover = b\n\t\tiover = a\nelse:\n\tover = min(a, b)\n\tif over == a:\n\t\tiover = b\n\t\ttake = c\n\t\titake = d\n\telse:\n\t\tiover = a\n\t\ttake = d\n\t\titake = c\nlcm = take * over // gcd(take, over)\nmul_1 = lcm // over\nmul_2 = lcm // take\n(over, iover) = map(lambda x: x * mul_1, [over, iover])\n(take, itake) = map(lambda x: x * mul_2, [take, itake])\na_1 = over * iover\na_2 = take * itake\nif a_1 > a_2:\n\t(num, den) = redc(over * iover - take * itake, over * iover)\nelse:\n\t(num, den) = redc(a_2 - a_1, a_2)\nprint(str(num) + '/' + str(den))\n", "def gcd(a, b):\n\tif a % b == 0:\n\t\treturn b\n\treturn gcd(b, a % b)\n(a, b, c, d) = map(int, input().split())\na *= c * d\nb *= c * d\nif a / c * d <= b:\n\ta = b - a / c * d\n\tg = gcd(a, b)\n\tprint(str(int(a / g)) + '/' + str(int(b / g)))\nelse:\n\tb = a - b / d * c\n\tg = gcd(a, b)\n\tprint(str(int(b / g)) + '/' + str(int(a / g)))\n", "import math\n(a, b, c, d) = map(int, input().split())\nl = a * d - b * c\nden = a * d\nif l < 0:\n\tl *= -1\n\tden = b * c\nif l == 0:\n\tprint('0/1')\nelse:\n\tprint(l // math.gcd(l, den), end='')\n\tprint('/', end='')\n\tprint(den // math.gcd(l, den))\n", "import math\n(a, b, c, d) = map(int, input().split())\n(x, y) = (a * d, b * c)\np = max(x, y) - min(x, y)\nq = max(x, y)\nz = math.gcd(p, q)\nprint(str(p // z) + '/' + str(q // z))\n", "import math\n(a, b, c, d) = map(int, input().split())\nb = b * c\nd = d * a\np = abs(b - d)\nq = max(b, d)\nx = math.gcd(p, q)\np //= x\nq //= x\nprint(p, '/', q, sep='')\n", "import sys\nsys.setrecursionlimit(100000)\n(a, b, c, d) = [int(x) for x in sys.stdin.readline().strip().split()]\n\ndef gcd(x, y):\n\tif x == 0:\n\t\treturn y\n\tif y == 0:\n\t\treturn x\n\tif x > y:\n\t\tx = x - y\n\t\treturn gcd(x, y)\n\telse:\n\t\ty = y - x\n\t\treturn gcd(x, y)\nca = gcd(c, a)\nc = c // ca\na = a // ca\ndb = gcd(d, b)\nb = b // db\nd = d // db\nab = gcd(a, b)\na = a // ab\nb = b // ab\ncd = gcd(c, d)\nc = c // cd\nd = d // cd\nif c * b <= d * a:\n\tnume = a * d - c * b\n\tdeno = a * d\n\tif nume == 0:\n\t\tdeno = 1\n\tprint(str(nume) + '/' + str(deno))\nelif c * b >= d * a:\n\tnume = c * b - a * d\n\tdeno = c * b\n\tif nume == 0:\n\t\tdeno = 1\n\tprint(str(nume) + '/' + str(deno))\n", "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n(a, b, c, d) = map(int, input().split())\ne = a\nf = e * d / c\ns1 = 1000000\ns2 = 1000000\nif f <= b:\n\ts1 = a * (b * c - a * d) / c\n\tv = a * (b * c - a * d)\n\tn = c * a * b\n\ttemp = gcd(v, n)\n\tt = str(v // temp) + '/' + str(n // temp)\nf = b\ne = f * c / d\nif e <= a:\n\ts2 = b * (a * d - b * c) / d\n\tv = b * (a * d - b * c)\n\tn = d * a * b\n\ttemp = gcd(v, n)\n\ts = str(v // temp) + '/' + str(n // temp)\nif s1 < s2:\n\tprint(t)\nelse:\n\tprint(s)\n", "import fractions\n(a, b, c, d) = map(int, input().split())\nf1 = fractions.Fraction(a, b)\nf2 = fractions.Fraction(c, d)\nl = fractions.Fraction(c, 1)\nw = fractions.Fraction(d, 1)\nx = fractions.Fraction(a * d, b)\ny = fractions.Fraction(b * c, a)\nans = fractions.Fraction(0, 1)\na = fractions.Fraction(l - x, l)\nb = fractions.Fraction(w - y, w)\nif a < 0:\n\tans = b\nelif b < 0:\n\tans = a\nelse:\n\tans = min(a, b)\nif ans.denominator == 1:\n\tprint(str(ans) + '/' + str(1))\nelse:\n\tprint(ans)\n", "(a, b, c, d) = [int(x) for x in input().split()]\n(total, empty) = (None, None)\nif a / b == c / d:\n\tprint('0/1')\nelif a / b > c / d:\n\ttotal = a * d\n\tempty = a * d - b * c\nelse:\n\ttotal = b * c\n\tempty = b * c - a * d\nif total != None:\n\tfor i in reversed(range(1, int(empty) + 1)):\n\t\tif empty % i == 0 and total % i == 0:\n\t\t\tempty = empty / i\n\t\t\ttotal = total / i\n\tprint('{}/{}'.format(int(empty), int(total)))\n", "(a, b, c, d) = map(int, input().split())\nif a / c > b / d:\n\t(a, b) = (b, a)\n\t(c, d) = (d, c)\nx = a * c\ny = a * d\nn = x * y\nd = a * b * c * c\nn = d - n\nfrom math import gcd\ng = gcd(n, d)\nn = n // g\nd = d // g\nprint(str(n) + '/' + str(d))\n", "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b, a % b)\n(a, b, c, d) = [int(s) for s in input().split()]\nif a / c < b / d:\n\tch = abs(a * d - b * c)\n\tzn = c * b\nelse:\n\tch = abs(b * c - a * d)\n\tzn = d * a\nnod = gcd(ch, zn)\nprint(str(ch // nod) + '/' + str(zn // nod))\n", "from sys import stdin, stdout\ninput = stdin.readline\nimport math, bisect\n\ndef gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n(a, b, c, d) = map(int, input().split())\nac1 = gcd(a, c)\nac = a * c // ac1\na1 = ac\nc1 = ac\nb1 = ac // a * b\nd1 = ac // c * d\nbd2 = gcd(b, d)\nbd = b * d // bd2\nb2 = bd\nd2 = bd\na2 = bd // b * a\nc2 = bd // d * c\nif b1 >= d1 and a2 >= c2:\n\tif (b1 - d1) // b1 < (a2 - c2) // a2:\n\t\tup = b1 - d1\n\t\tdw = b1\n\telse:\n\t\tup = a2 - c2\n\t\tdw = a2\nelif b1 >= d1:\n\tup = b1 - d1\n\tdw = b1\nelse:\n\tup = a2 - c2\n\tdw = a2\ng = gcd(up, dw)\nprint(up // g, end='/')\nprint(dw // g)\n", "(a, b, c, d) = list(map(int, input().split()))\n(actual, free) = (0, 0)\nif a / b < c / d:\n\tfree = b * c - a * d\n\tactual = b * c\nelif a / b > c / d:\n\tfree = a * d - b * c\n\tactual = a * d\nelse:\n\tprint('0/1')\n\texit()\nimport fractions\ngcd = fractions.gcd(free, actual)\nprint(int(free / gcd), end='')\nprint('/', end='')\nprint(int(actual / gcd), end='')\n", "def check(t):\n\tif x == int(x):\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef gcd(x, y):\n\tif x % y == 0:\n\t\treturn y\n\telse:\n\t\treturn gcd(y, x % y)\n(a, b, c, d) = map(int, input().split())\na *= max(c, d)\nb *= max(c, d)\nr = c / d\nif a / b < r:\n\tx = b * c - a * d\n\tb = b * c\n\tu = gcd(x, b)\n\tp = str(int(x / u)) + '/' + str(int(b / u))\n\tprint(p)\nelse:\n\tx = a * d - c * b\n\ta = a * d\n\tu = gcd(x, a)\n\tp = str(int(x / u)) + '/' + str(int(a / u))\n\tprint(p)\n", "def gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\treturn gcd(b % a, a)\n(a, b, c, d) = map(int, input().strip().split())\n(nr, dr) = (0, 0)\nif a / b == c / d:\n\tprint('0/1')\nelif a / b > c / d:\n\tnr = a * d - b * c\n\tdr = a * d\n\tcommDiv = gcd(nr, dr)\n\tprint(str(nr // commDiv) + '/' + str(dr // commDiv))\nelse:\n\tnr = b * c - a * d\n\tdr = b * c\n\tcommDiv = gcd(nr, dr)\n\tprint(str(nr // commDiv) + '/' + str(dr // commDiv))\n", "from fractions import Fraction\ninp = input()\narr = inp.split(' ')\na = Fraction(int(arr[0]), 1)\nb = Fraction(int(arr[1]), 1)\nc = Fraction(int(arr[2]), 1)\nd = Fraction(int(arr[3]), 1)\nif d * a == c * b:\n\tans = Fraction(0, 1)\nelif d * a < c * b:\n\tans = (b - d * (a / c)) / b\nelse:\n\tans = (a - c * (b / d)) / a\nprint(ans.numerator, end='')\nprint('/', end='')\nprint(ans.denominator)\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\n(x, y) = (a * d, b * c)\nz = Fraction(max(x, y) - min(x, y), max(x, y))\nif float(z) == 0:\n\tprint('0/1')\nelse:\n\tprint(z)\n", "import math\n(a, b, c, d) = list(map(int, input().split()))\nif c / d > a / b:\n\tp = b * c - a * d\n\tq = b * c\nelse:\n\tp = a * d - b * c\n\tq = a * d\nfor i in range(2, p + 1):\n\tif p % i == 0 and q % i == 0:\n\t\twhile p % i == 0 and q % i == 0:\n\t\t\tp = p // i\n\t\t\tq = q // i\nif p == 0:\n\tq = 1\nprint(str(p) + '/' + str(q))\n", "(a, b, c, d) = [int(x) for x in input().split()]\nif b / a > d / c:\n\tu = b * c - a * d\n\tv = b * c\nelse:\n\tu = a * d - b * c\n\tv = a * d\nfor i in range(2, min(u, v) + 1):\n\twhile u % i == 0 and v % i == 0:\n\t\tu = u // i\n\t\tv = v // i\nif u == 0:\n\tprint('0/1')\nelse:\n\tprint(str(u) + '/' + str(v))\n", "import sys\nfrom math import gcd\ninput = lambda : sys.stdin.readline().strip('\\r\\n')\n(a, b, c, d) = map(int, input().split())\n(x, y) = (abs(a * d - b * c), max(a * d, b * c))\nd = gcd(x, y)\nprint('{}/{}'.format(x // d, y // d))\n", "from fractions import Fraction\nfrom decimal import Decimal\n(a, b, c, d) = map(int, input().split())\nans = max(Fraction((a * d - b * c) / (a * d)).limit_denominator(), Fraction((b * c - a * d) / (b * c)).limit_denominator())\nif ans == 0:\n\tans = '0/1'\nprint(ans)\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\np = a / b\nq = c / d\nif q > p:\n\ta = Fraction(b * c - a * d, b * c)\n\tprint(a if a else '0/1')\nelse:\n\ta = Fraction(a * d - b * c, a * d)\n\tprint(a if a else '0/1')\n", "from math import gcd\n(a, b, c, d) = map(int, input().split())\np = abs(a * d - b * c)\nif a / b > c / d:\n\tq = a * d\nelif a / b < c / d:\n\tq = b * c\nelse:\n\tprint('0/1')\n\texit()\nprint(str(int(p / gcd(p, q))) + '/' + str(int(q / gcd(p, q))))\n", "def main():\n\tfrom fractions import Fraction\n\t(a, b, c, d) = map(int, input().split(' '))\n\tf = Fraction(a * d - b * c, a * d)\n\tif a * d <= b * c:\n\t\tf = Fraction(b * c - a * d, b * c)\n\tprint('{}/{}'.format(f.numerator, f.denominator))\nmain()\n", "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b, a % b)\n(a, b, c, d) = map(int, input().split())\n(p1, q1) = (a, c)\n(p2, q2) = (b, d)\narea1 = a * d * p1 / q1\narea2 = c * (p2 / q2) * b\nif p1 / q1 * d <= b and p2 / q2 * c <= a:\n\tif area1 > area2:\n\t\t(p, q) = (p1, q1)\n\telse:\n\t\t(p, q) = (p2, q2)\nelif p1 / q1 * d <= b and (not p2 / q2 * c <= a):\n\t(p, q) = (p1, q1)\nelif not p1 / q1 * d <= b and p2 / q2 * c <= a:\n\t(p, q) = (p2, q2)\nif c % q == 0:\n\tc = c * p // q\nelse:\n\td = d * p // q\nremaining_n = q * a * b - c * d * p\nremaining_d = q * a * b\ns = '{}/{}'\nprint(s.format(remaining_n // gcd(remaining_n, remaining_d), remaining_d // gcd(remaining_n, remaining_d)))\n", "def GCD(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn GCD(b, a % b)\n(n, k, l, m) = map(int, input().strip().split())\nk = k * l\nm = m * n\n(a, b) = (int(abs(k - m)), int(max(k, m)))\nx = GCD(a, b)\na //= x\nb //= x\nprint(a, '/', b, sep='')\n", "from fractions import Fraction\nfrom sys import exit\n(a, b, c, d) = map(float, input().split())\nif a / b < c / d:\n\tsol = (b * c - a * d) / (b * c)\nelif a / b > c / d:\n\tsol = (a * d - b * c) / (a * d)\nelse:\n\tprint('0/1')\n\texit(0)\nprint(Fraction(sol).limit_denominator())\n", "from fractions import gcd\n\ndef Irreducible_Fraction(A, B):\n\tx = gcd(A, B)\n\treturn [A // x, B // x]\n(a, b, c, d) = map(int, input().split())\nF = a / b\nS = c / d\na / b < c / d\na / b == c / d\na / b > c / d\nif a / b < c / d:\n\tstretching_factor = a / c\n\tNew_horizontal = a\n\tNew_vertical = a * d\n\tNew_Movie_Area = int(New_horizontal * New_vertical)\n\tScreen_Area = int(a * b * c)\n\tEmpty_Area = Screen_Area - New_Movie_Area\n\tdesired_ratio = Irreducible_Fraction(Empty_Area, Screen_Area)\n\tnominator = desired_ratio[0]\n\tdenominator = desired_ratio[1]\n\tprint(nominator, end='/')\n\tprint(denominator)\nelif a / b == c / d:\n\tprint('0/1')\nelse:\n\tstretching_factor = b / d\n\tNew_vertical = b\n\tNew_horizontal = b * c\n\tNew_Movie_Area = int(New_horizontal * New_vertical)\n\tScreen_Area = int(a * b * d)\n\tEmpty_Area = Screen_Area - New_Movie_Area\n\tdesired_ratio = Irreducible_Fraction(Empty_Area, Screen_Area)\n\tnominator = desired_ratio[0]\n\tdenominator = desired_ratio[1]\n\tprint(nominator, end='/')\n\tprint(denominator)\n", "import sys\nfrom math import sqrt\nfrom fractions import Fraction\ninput = sys.stdin.readline\n\ndef inp():\n\treturn int(input())\n\ndef inlt():\n\treturn list(map(int, input().split()))\n\ndef insr():\n\ts = input()\n\treturn list(s[:len(s) - 1])\n\ndef invr():\n\treturn map(int, input().split())\n(a, b, c, d) = invr()\nnewW = c * b / d\nnewH = d * a / c\nres = '{}/{}'.format(0, 1)\nif newW < a:\n\tres = str(Fraction((a - newW) / a).limit_denominator())\nelif newH < b:\n\tres = str(Fraction((b - newH) / b).limit_denominator())\nprint(res)\n", "from fractions import Fraction\nfrom math import gcd\n(a, b, c, d) = map(int, input().split())\narea = a * b\nx_num = a * d\nx_den = c\nx = x_num / x_den\narea1 = x * a\ny_num = b * c\ny_den = d\ny = y_num / y_den\narea2 = y * b\nif area2 > area or y > a:\n\tarea2 = 0\nif area1 > area or x > b:\n\tarea1 = 0\nif area1 >= area2:\n\tleft_num = b * x_den - x_num\n\tp_num = left_num * a\n\tp_den = x_den\n\thm_num = p_num\n\thm_den = p_den * area\n\tz = gcd(hm_num, hm_den)\n\tans_num = hm_num // z\n\tans_den = hm_den // z\n\tans = str(ans_num) + '/' + str(ans_den)\nif area1 <= area2:\n\tleft_num = a * y_den - y_num\n\tp_num = left_num * b\n\tp_den = y_den\n\thm_num = p_num\n\thm_den = p_den * area\n\tz = gcd(hm_num, hm_den)\n\tans_num = hm_num // z\n\tans_den = hm_den // z\n\tans = str(ans_num) + '/' + str(ans_den)\nprint(ans)\n", "import fractions as f\nimport math\n(a, b, c, d) = map(int, input().split(' '))\nif a == b and c == d:\n\tprint('0/1')\n\tquit()\nelif a == b and c != d:\n\tnew = f.Fraction(f.Fraction(b, 1) / f.Fraction(c, d))\n\tfilmArea = f.Fraction(a, 1) * new\n\tscreenArea = f.Fraction(a * a, 1)\nelif a != b and c == d:\n\tfilmArea = f.Fraction(min(a, b) ** 2, 1)\n\tscreenArea = f.Fraction(a * b, 1)\nelif a != b and c != d:\n\tif a / (c / d) <= b:\n\t\tnew = f.Fraction(f.Fraction(a, 1) / f.Fraction(c, d))\n\t\tfilmArea = f.Fraction(a, 1) * new\n\t\tscreenArea = f.Fraction(a * b, 1)\n\telse:\n\t\tnew = f.Fraction(b * c, d)\n\t\tfilmArea = f.Fraction(b, 1) * new\n\t\tscreenArea = f.Fraction(a * b, 1)\nblackScreen = f.Fraction(1, 1) - filmArea / screenArea\nprint(blackScreen)\n", "from math import gcd\nfrom fractions import Fraction\n\ndef reduce_fraction(x, y):\n\td = gcd(x, y)\n\tx = x // d\n\ty = y // d\n\tfrac = Fraction(x / y).limit_denominator()\n\tprint(frac)\n(a, b, c, d) = map(int, input().split())\nhorizontal_space = b * c - a * d\nvertical_space = a * d - b * c\nflag = False\nif horizontal_space == vertical_space:\n\tprint('0/1')\n\tflag = True\nelif horizontal_space > 0:\n\tnumerator = horizontal_space\n\tdenominator = b * c\nelif vertical_space > 0:\n\tnumerator = vertical_space\n\tdenominator = a * d\nif not flag:\n\treduce_fraction(numerator, denominator)\n", "from fractions import Fraction\n(a, b, c, d) = list(map(int, input().split()))\nif b * c / d <= a:\n\tk = Fraction(b, d)\nelse:\n\tk = Fraction(a, c)\nans = Fraction(1 - Fraction(k * c * k * d, a * b))\nif str(ans) == '0':\n\tprint('0/1')\nelse:\n\tprint(str(ans))\n", "def gdc(a, b):\n\twhile b != 0:\n\t\t(a, b) = (b, a % b)\n\treturn a\nvals = [int(x) for x in input().split()]\na = vals[0]\nb = vals[1]\nc = vals[2]\nd = vals[3]\nx = 0\ny = 0\nif a / b >= c / d:\n\tx = abs(d * a - c * b)\n\ty = d * a\nelse:\n\tx = abs(c * b - a * d)\n\ty = c * b\ngdcXandY = gdc(max(x, y), min(x, y))\nx /= gdcXandY\ny /= gdcXandY\nprint(f'{int(x)}/{int(y)}')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nx = a * d\ny = b * c\n(x, y) = (min(x, y), max(x, y))\nans = Fraction(abs(1 - Fraction(x / y).limit_denominator()))\nif ans == 0:\n\tprint(f'{ans}/1')\nelse:\n\tprint(ans)\n", "(sw, sh, fw, fh) = [int(x) for x in input().split()]\ngcd = lambda a, b: b if a == 0 else gcd(b % a, a)\nif sw * fh < fw * sh:\n\tfa = sw * sw * fh\n\tsa = sw * sh * fw\nelse:\n\tfa = sh * sh * fw\n\tsa = sw * sh * fh\nd = gcd(sa - fa, sa)\nprint((sa - fa) // d, '/', sa // d, sep='')\n", "import math\nimport sys\ninput = sys.stdin.readline\n\ndef inp():\n\treturn int(input())\n\ndef inlt():\n\treturn list(map(int, input().split()))\n\ndef insr():\n\ts = input()\n\treturn s[:len(s) - 1]\n\ndef invr():\n\treturn map(int, input().split())\n\ndef print_fract(p, q):\n\tg = math.gcd(p, q)\n\tp //= g\n\tq //= g\n\tprint(str(p) + '/' + str(q))\n(a, b, c, d) = invr()\nif a >= c and b >= d or (a < c and b < d):\n\tfl = True\n\tarea = 0\n\tif d * (a / c) <= b:\n\t\tarea = d * a * a / c\n\tif c * (b / d) <= a:\n\t\tif area < c * b * b / d:\n\t\t\tfl = False\n\t\t\tp = a * d - b * c\n\t\t\tq = a * d\n\t\t\tprint_fract(p, q)\n\tif fl:\n\t\tp = b * c - a * d\n\t\tq = b * c\n\t\tprint_fract(p, q)\nelif a >= c and b < d:\n\tp = a * d - b * c\n\tq = a * d\n\tprint_fract(p, q)\nelif a < c and b >= d:\n\tp = b * c - a * d\n\tq = b * c\n\tprint_fract(p, q)\n", "from fractions import Fraction as f\ninps = list(map(int, input().split()))\n(a, b, c, d) = (inps[0], inps[1], inps[2], inps[3])\nif a / b < c / d:\n\tprint(f(b * c - a * d, b * c))\nelif a / b > c / d:\n\tprint(f(a * d - b * c, a * d))\nelse:\n\tprint('0/1')\n", "def main():\n\t(a, b, c, d) = map(int, input().split())\n\tans = '0/1'\n\tif a / b > c / d:\n\t\tans = fractions.Fraction(d * a - b * c, d * a)\n\telif a / b < c / d:\n\t\tans = fractions.Fraction(c * b - a * d, c * b)\n\tprint(ans)\nimport os\nimport sys\nimport fractions\nimport itertools\nimport math\nfrom io import BytesIO, IOBase\nBUFFER_SIZE = 8192\n\nclass FastIO(IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = 'x' in file.mode or 'r' not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFER_SIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFER_SIZE))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\n\tdef flush(self):\n\t\tif self.writable:\n\t\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass IOWrapper(IOBase):\n\n\tdef __init__(self, file):\n\t\tself.buffer = FastIO(file)\n\t\tself.flush = self.buffer.flush\n\t\tself.writable = self.buffer.writable\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))\ninput = lambda : sys.stdin.readline().rstrip('\\r\\n')\nmain()\n", "def gcd_euclid(den, num):\n\tif num == 0:\n\t\treturn den\n\treturn gcd_euclid(num, den % num)\n(a, b, c, d) = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\nnumerator = 0\ndenominator = 0\nif d * (a / c) <= b:\n\t(a, b, c, d) = (a * c, b * c, c * a, d * a)\n\tnumerator = b - d\n\tdenominator = b\nelse:\n\t(a, b, c, d) = (a * d, b * d, c * b, d * b)\n\tnumerator = a - c\n\tdenominator = a\ngcd = gcd_euclid(denominator, numerator)\nprint(str(numerator // gcd) + '/' + str(denominator // gcd))\n", "import math\n(a, b, c, d) = map(int, input().split())\na1 = 100\nc1 = 100\nb1 = [b * 100, a]\nd1 = [d * 100, c]\nx = math.gcd(b1[0], b1[1])\ny = math.gcd(d1[0], d1[1])\nb1[0] //= x\nb1[1] //= x\nd1[0] //= y\nd1[1] //= y\nif d1[0] == b1[0] and d1[1] == b1[1]:\n\tprint('0/1')\nelif d1[0] * b1[1] < d1[1] * b1[0]:\n\tx = b1[0] * d1[1] - d1[0] * b1[1]\n\ty = b1[1] * d1[1]\n\tnum = x * b1[1]\n\tdeno = y * b1[0]\n\tp = math.gcd(num, deno)\n\tnum //= p\n\tdeno //= p\n\tprint(str(num) + '/' + str(deno))\nelse:\n\tb2 = 100\n\td2 = 100\n\ta2 = [a * 100, b]\n\tc2 = [c * 100, d]\n\tx = math.gcd(a2[0], a2[1])\n\ty = math.gcd(c2[0], c2[1])\n\ta2[0] //= x\n\ta2[1] //= x\n\tc2[0] //= y\n\tc2[1] //= y\n\tx = a2[0] * c2[1] - c2[0] * a2[1]\n\ty = a2[1] * c2[1]\n\tnum = x * a2[1]\n\tdeno = y * a2[0]\n\tp = math.gcd(num, deno)\n\tnum //= p\n\tdeno //= p\n\tprint(str(num) + '/' + str(deno))\n", "def hcf(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn hcf(b, a % b)\n(a, b, c, d) = map(int, input().split())\nb *= c\nd *= a\ne = abs(b - d)\nf = max(b, d)\ng = hcf(e, f)\ne //= g\nf //= g\nprint(e, '/', f, sep='')\n", "def main():\n\tfrom math import gcd\n\t(a, b, c, d) = map(int, input().split())\n\ta *= d\n\tb *= c\n\tif a > b:\n\t\t(a, b) = (b, a)\n\tc = gcd(a, b)\n\tprint('/'.join(map(str, ((b - a) // c, b // c))))\nmain()\n", "import math\n(a, b, c, d) = map(int, input().split())\nif d * a / c <= b:\n\tnum = a * b * c - a * a * d\n\tden = a * b * c\nelse:\n\tnum = b * a * d - c * b * b\n\tden = a * b * d\ng = math.gcd(num, den)\nprint(str(num // g) + '/' + str(den // g))\n", "def inp(n):\n\tif n == 1:\n\t\treturn map(int, stdin.readline().split())\n\telif n == 2:\n\t\treturn map(float, stdin.readline().split())\n\telse:\n\t\treturn map(str, stdin.readline().split())\nfrom sys import stdin\nfrom fractions import Fraction\nfrom math import gcd\n(a, b, c, d) = inp(1)\nif c <= a:\n\t(area2, area1) = (a * b, a * (d * (a / c)))\n\t(ma, mi) = (max(area1, area2), min(area2, area1))\nelse:\n\t(area2, area1) = (c * d, c * (b * (c / a)))\n\t(ma, mi) = (max(area1, area2), min(area2, area1))\nans = (Fraction(str(mi)) / Fraction(str(ma))).limit_denominator()\nif ans != 1:\n\tprint(1 - ans)\nelse:\n\tprint('0/1')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nans = Fraction(abs(a * d - c * b) / max(a * d, b * c)).limit_denominator()\nprint('0/1' if not ans else ans)\n", "from fractions import gcd\n\ndef socr(a, b):\n\ttmp = gcd(a, b)\n\treturn (a // tmp, b // tmp)\n(a, b, c, d) = list(map(int, input().split()))\nans = socr(a * d - b * c, a * d)\n(a, b) = (b, a)\n(c, d) = (d, c)\nans = socr(a * d - b * c, a * d) if ans[0] < 0 or ans[1] < 0 else ans\nprint(str(int(ans[0])) + '/' + str(int(ans[1])))\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nif c / a > d / b:\n\td = d * (a / c)\n\tc = a\n\tk = b - d\n\te = k / b\nelif c / a < d / b:\n\tc = c * (b / d)\n\td = b\n\tk = a - c\n\te = k / a\nelse:\n\tprint('0/1')\n\texit()\nprint(Fraction(e).limit_denominator())\n", "import sys\n(a, b, c, d) = [int(x) for x in input().split()]\n\ndef find(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn find(b, a % b)\np = c * d\na = a * p\nb = b * p\nk1 = a // c\nk2 = b // d\nif k1 == k2:\n\tprint('0/1')\n\tsys.exit()\nk = min(k1, k2)\nif k * c == a:\n\trem = b - k * d\n\tlcm = find(b, rem)\n\trem = rem // lcm\n\tb = b // lcm\n\tprint('{}/{}'.format(rem, b))\nelif k * d == b:\n\trem = a - k * c\n\tlcm = find(a, rem)\n\trem = rem // lcm\n\ta = a // lcm\n\tprint('{}/{}'.format(rem, a))\n", "def gcd(a, b):\n\twhile a != 0:\n\t\t(a, b) = (b % a, a)\n\treturn b\n(a, b, c, d) = map(int, input().split())\nb *= c\nd *= a\ne = abs(b - d)\nf = max(b, d)\ng = gcd(e, f)\ne //= g\nf //= g\nprint(e, '/', f, sep='')\n", "import os\nimport sys\nfrom math import *\nfrom collections import *\nfrom bisect import *\nfrom io import BytesIO, IOBase\nfrom fractions import *\n\ndef vsInput():\n\tsys.stdin = open('input.txt', 'r')\n\tsys.stdout = open('output.txt', 'w')\nBUFSIZE = 8192\n\nclass FastIO(IOBase):\n\tnewlines = 0\n\n\tdef __init__(self, file):\n\t\tself._fd = file.fileno()\n\t\tself.buffer = BytesIO()\n\t\tself.writable = 'x' in file.mode or 'r' not in file.mode\n\t\tself.write = self.buffer.write if self.writable else None\n\n\tdef read(self):\n\t\twhile True:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tif not b:\n\t\t\t\tbreak\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines = 0\n\t\treturn self.buffer.read()\n\n\tdef readline(self):\n\t\twhile self.newlines == 0:\n\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\n\t\t\tself.newlines = b.count(b'\\n') + (not b)\n\t\t\tptr = self.buffer.tell()\n\t\t\t(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))\n\t\tself.newlines -= 1\n\t\treturn self.buffer.readline()\n\n\tdef flush(self):\n\t\tif self.writable:\n\t\t\tos.write(self._fd, self.buffer.getvalue())\n\t\t\t(self.buffer.truncate(0), self.buffer.seek(0))\n\nclass IOWrapper(IOBase):\n\n\tdef __init__(self, file):\n\t\tself.buffer = FastIO(file)\n\t\tself.flush = self.buffer.flush\n\t\tself.writable = self.buffer.writable\n\t\tself.write = lambda s: self.buffer.write(s.encode('ascii'))\n\t\tself.read = lambda : self.buffer.read().decode('ascii')\n\t\tself.readline = lambda : self.buffer.readline().decode('ascii')\n(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))\ninput = lambda : sys.stdin.readline().rstrip('\\r\\n')\n\ndef value():\n\treturn tuple(map(int, input().split()))\n\ndef array():\n\treturn [int(i) for i in input().split()]\n\ndef Int():\n\treturn int(input())\n\ndef Str():\n\treturn input()\n\ndef arrayS():\n\treturn [i for i in input().split()]\n\ndef Lcm(a, b):\n\treturn a * b // gcd(a, b)\n\ndef check(mon, fra):\n\tlcm = Lcm(mon[1], fra[1])\n\tmon = mon[0] * lcm // mon[1]\n\tfra = fra[0] * lcm // fra[1]\n\tif mon < fra:\n\t\treturn inf\n\treturn Fraction(mon - fra, mon)\n(a, b, c, d) = value()\nmon = [a, b]\nfra = [c, d]\nans = min(check(mon, fra), check(mon[::-1], fra[::-1]))\nif ans.numerator == 0:\n\tprint('0/1')\nelse:\n\tprint(ans)\n", "import sys\nimport string\nimport math\nfrom collections import defaultdict\nfrom functools import lru_cache\nfrom collections import Counter\nfrom fractions import Fraction\n\ndef mi(s):\n\treturn map(int, s.strip().split())\n\ndef lmi(s):\n\treturn list(mi(s))\n\ndef tmi(s):\n\treturn tuple(mi(s))\n\ndef mf(f, s):\n\treturn map(f, s)\n\ndef lmf(f, s):\n\treturn list(mf(f, s))\n\ndef js(lst):\n\treturn ' '.join((str(d) for d in lst))\n\ndef line():\n\treturn sys.stdin.readline().strip()\n\ndef linesp():\n\treturn line().split()\n\ndef iline():\n\treturn int(line())\n\ndef mat(n):\n\tmatr = []\n\tfor _ in range(n):\n\t\tmatr.append(linesp())\n\treturn matr\n\ndef mati(n):\n\tmat = []\n\tfor _ in range(n):\n\t\tmat.append(lmi(line()))\n\treturn mat\n\ndef pmat(mat):\n\tfor row in mat:\n\t\tprint(js(row))\n\ndef dist(x, y):\n\treturn ((x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2) ** 0.5\n\ndef fast_exp(x, n):\n\tif n == 0:\n\t\treturn 1\n\telif n % 2 == 1:\n\t\treturn x * fast_exp(x, (n - 1) // 2) ** 2\n\telse:\n\t\treturn fast_exp(x, n // 2) ** 2\n\ndef gcd(a, b):\n\twhile b:\n\t\ta %= b\n\t\t(a, b) = (b, a)\n\treturn a\n\ndef main(c, d, a, b):\n\tans = []\n\tb2 = Fraction(b * c, a)\n\tif b2 <= Fraction(d, 1):\n\t\tans.append(Fraction(b * c ** 2, a))\n\ta2 = Fraction(a * d, b)\n\tif a2 <= Fraction(c, 1):\n\t\tans.append(Fraction(a * d ** 2, b))\n\tlowest = float('inf')\n\tfor frac in ans:\n\t\tlowest = min(lowest, 1 - frac / Fraction(c * d, 1))\n\tif lowest == 0:\n\t\tprint('0/1')\n\t\treturn\n\tprint(lowest / gcd(lowest.numerator, lowest.denominator))\narr = lmi(line())\nmain(*arr)\n", "from math import gcd\n(a, b, c, d) = map(int, input().split())\nW = a * c / gcd(a, c)\nH = W / a * b\nw = W\nh = W / c * d\nif H - h < 0:\n\tH = b * d / gcd(b, d)\n\tW = H / b * a\n\tw = H / d * c\n\th = H\nif W == w:\n\tp = int(H - h)\n\tq = int(H)\n\tgcdd = int(gcd(p, q))\n\tp = int(p / gcdd)\n\tq = int(q / gcdd)\nelse:\n\tp = int(W - w)\n\tq = int(W)\n\tgcdd = int(gcd(p, q))\n\tp = int(p / gcdd)\n\tq = int(q / gcdd)\nprint(str(p) + '/' + str(q))\n", "def mi():\n\treturn map(int, input().split())\n(a, b, c, d) = mi()\nfrom math import gcd\nif a / b < c / d:\n\tnum = b * c - a * d\n\tden = b * c\nelif a / b > c / d:\n\tnum = a * d - b * c\n\tden = a * d\nelse:\n\tnum = 0\n\tden = 1\nnd = gcd(num, den)\nprint(num // nd, '/', den // nd, sep='')\n", "def zip_sorted(a, b):\n\t(a, b) = zip(*sorted(zip(a, b)))\n\tsorted(zip(a, b), key=lambda x: x[1])\n\treturn (a, b)\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int, input().split()))\nS = lambda : list(map(str, input().split()))\n\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n(a, b, c, d) = I()\nif a / b == c / d:\n\tprint(str(0) + '/' + '1')\nelse:\n\tif a * d - c * b > 0:\n\t\tprint(str(int((-(b * c) + a * d) / gcd(-(b * c) + a * d, a * d))) + '/' + str(int(a * d / gcd(-(b * c) + a * d, a * d))))\n\tif b * c - a * d > 0:\n\t\tprint(str(int((b * c - a * d) / gcd(b * c - a * d, b * c))) + '/' + str(int(b * c / gcd(b * c - a * d, b * c))))\n", "def gcd(a, b):\n\twhile b > 0:\n\t\t(a, b) = (b, a % b)\n\treturn a\n\ndef byt(lst):\n\tif lst[0] * lst[3] > lst[1] * lst[2]:\n\t\ttmp = lst[0]\n\t\tlst[0] = lst[1]\n\t\tlst[1] = tmp\n\t\ttmp = lst[2]\n\t\tlst[2] = lst[3]\n\t\tlst[3] = tmp\n\tm = (lst[1] * lst[2] - lst[0] * lst[3]) * lst[3]\n\tn = lst[1] * lst[2] * lst[3]\n\tg = gcd(m, n)\n\treturn str(m // g) + '/' + str(n // g)\n(a, b, c, d) = [int(i) for i in input().split()]\nprint(byt(list((a, b, c, d))))\n", "(a, b, c, d) = map(int, input().split())\nad = a * d\nbc = b * c\nup = min(ad, bc)\ndown = max(ad, bc)\nup = down - up\nfor i in range(down, 1, -1):\n\tif up % i == 0 and down % i == 0:\n\t\tup /= i\n\t\tdown /= i\nprint(str(int(up)) + '/' + str(int(down)))\n", "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n(a, b, c, d) = list(map(int, input().split()))\nif a * d < c * b:\n\thcf = gcd(b * c - a * d, b * c)\n\tprint(str(int((b * c - a * d) / hcf)) + '/' + str(int(b * c / hcf)))\nelif a * d > c * b:\n\thcf = gcd(a * d - b * c, a * d)\n\tprint(str(int((a * d - b * c) / hcf)) + '/' + str(int(a * d / hcf)))\nelse:\n\tprint('0/1')\n", "def gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\telse:\n\t\treturn gcd(b % a, a)\n\ndef main():\n\t(a, b, c, d) = map(int, input().split())\n\tif a / b < c / d:\n\t\tprint(f'{(b * c - a * d) // gcd(b * c - a * d, b * c)}/{b * c // gcd(b * c - a * d, b * c)}')\n\telif a / b >= c / d:\n\t\tprint(f'{(a * d - b * c) // gcd(a * d - b * c, a * d)}/{a * d // gcd(a * d - b * c, a * d)}')\nmain()\n", "import math\n(a, b, c, d) = map(int, input().split())\ny = min(a / c, b / d)\nif y == a / c:\n\tn = a * b * c ** 2 - c * d * a ** 2\n\td = a * b * c ** 2\nelse:\n\tn = a * b * d ** 2 - c * d * b ** 2\n\td = a * b * d ** 2\nx = math.gcd(n, d)\nprint('%d/%d' % (n / x, d / x))\n", "(a, b, c, d) = [int(i) for i in input().split()]\nx = 0\nif b * c < a * d:\n\tx = a\n\ta = b\n\tb = x\n\tx = d\n\td = c\n\tc = x\nq = b * c\np = q - a * d\nfor i in range(2, q + 1):\n\twhile p % i == 0 and q % i == 0:\n\t\tp //= i\n\t\tq //= i\nprint(str(p) + '/' + str(q))\n", "import math\nimport sys\ninput = sys.stdin.readline\n\ndef inp():\n\treturn int(input())\n\ndef inlt():\n\treturn list(map(int, input().split()))\n\ndef insr():\n\ts = input()\n\treturn s[:len(s) - 1]\n\ndef invr():\n\treturn map(int, input().split())\n\ndef print_fract(p, q):\n\tg = math.gcd(p, q)\n\tp //= g\n\tq //= g\n\tprint(str(p) + '/' + str(q))\n(a, b, c, d) = invr()\nif d * (a / c) <= b:\n\tp = b * c - a * d\n\tq = b * c\n\tprint_fract(p, q)\nelse:\n\tp = a * d - b * c\n\tq = a * d\n\tprint_fract(p, q)\n", "from math import gcd\n(a, b, c, d) = map(int, input().split())\nif a / b > c / d:\n\ta *= d\n\tc *= b\n\tprint((a - c) // gcd(a - c, a), a // gcd(a - c, a), sep='/')\nelse:\n\tc *= b\n\ta *= d\n\tprint((c - a) // gcd(c - a, c), c // gcd(c - a, c), sep='/')\n", "from math import gcd\n\ndef lcm(x, y):\n\treturn x * y // gcd(x, y)\n\ndef solve(a, b, c, d):\n\tk1 = lcm(a, c) // a\n\tk2 = lcm(a, c) // c\n\ta *= k1\n\tb *= k1\n\tc *= k2\n\td *= k2\n\thi = a * b - c * d\n\tlo = a * b\n\tif d <= b:\n\t\treturn (hi // gcd(hi, lo), lo // gcd(hi, lo))\n\telse:\n\t\treturn None\n(a, b, c, d) = map(int, input().split())\nv = solve(a, b, c, d)\nh = solve(b, a, d, c)\nif v is not None and h is not None:\n\tprint('0/1')\nelif v is not None:\n\tprint('{}/{}'.format(v[0], v[1]))\nelse:\n\tprint('{}/{}'.format(h[0], h[1]))\n", "(a, b, c, d) = map(int, input().split())\n\ndef gcd(a, b):\n\tif b > a:\n\t\treturn gcd(b, a)\n\telif not a % b:\n\t\treturn b\n\telse:\n\t\treturn gcd(b, a % b)\nif a / c > b / d:\n\tnum = a * d - b * c\n\tden = a * d\nelse:\n\tnum = b * c - a * d\n\tden = b * c\nif num > 0:\n\tk = gcd(num, den)\n\tnum = num // k\n\tden = den // k\nelse:\n\tden = 1\nprint(str(num) + '/' + str(den))\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nv = Fraction(abs(a * d - b * c), max(a * d, b * c))\nprint(v.numerator, '/', v.denominator, sep='')\n", "from math import gcd\n\ndef lcm(a, b):\n\treturn abs(a * b) // gcd(a, b)\n(a, b, c, d) = map(int, input().split())\nif a / c * d < b:\n\tac = lcm(a, c)\n\tb *= ac // a\n\td *= ac // c\n\tnumerator = ac * b - ac * d\n\tdenominator = ac * b\nelse:\n\tbd = lcm(b, d)\n\ta *= bd // b\n\tc *= bd // d\n\tnumerator = bd * a - bd * c\n\tdenominator = bd * a\ndivisor = gcd(numerator, denominator)\nprint(str(numerator // divisor) + '/' + str(denominator // divisor))\n", "import math\nfrom fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nif c / d > a / b:\n\tconversion = Fraction(a, c)\n\td *= conversion\n\tres = Fraction(b - d, b)\n\tif res == 0:\n\t\tprint(str(res) + '/' + str(1))\n\tprint(res)\nelse:\n\tconversion = Fraction(b, d)\n\tc *= conversion\n\tres = Fraction(a - c, a)\n\tif res == 0:\n\t\tprint(str(res) + '/' + str(1))\n\telse:\n\t\tprint(res)\n", "def ii():\n\treturn int(input())\n\ndef si():\n\treturn input()\n\ndef mi():\n\treturn map(int, input().split())\n\ndef li():\n\treturn list(mi())\nimport math\nfrom fractions import Fraction\n(a, b, c, d) = mi()\nif a / b < c / d:\n\tans = b * c - a * d\n\tans2 = b * c\nelse:\n\tans = a * d - b * c\n\tans2 = a * d\ne = math.gcd(ans, ans2)\nans //= e\nans2 //= e\nprint(str(ans) + '/' + str(ans2))\n", "from fractions import Fraction as f\n(a, b, c, d) = map(int, input().split())\nA = f(a, b)\nB = f(c, d)\nm = f(abs(d * a - b * c), max(d * a, b * c))\nn = f(abs(a * d - c * b), max(a * d, c * b))\nans = min(m, n)\nprint(str(ans.numerator) + '/' + str(ans.denominator))\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\n(m1, m2) = (99999999, 99999999)\nif c * (b / a) >= d:\n\ttemp = Fraction(c * b, a)\n\tx = temp - d\n\tm1 = Fraction(x * c, c * temp)\nelif d * (a / b) >= c:\n\ttemp = Fraction(d * a, b)\n\tx = temp - c\n\tm2 = Fraction(x * d, d * temp)\ns = str(min(m1, m2))\ng = s.split('/')\nif len(g) == 2:\n\tprint(s)\nelse:\n\tprint(s + '/' + '1')\n", "from fractions import gcd, Fraction, Decimal\n(a, b, c, d) = map(int, input().split())\nif a / b < c / d:\n\tN = b * c - a * d\n\tD = b * c\nelse:\n\tN = a * d - b * c\n\tD = a * d\nx = gcd(N, D)\nprint(N // x, end='/')\nprint(D // x)\n", "import math\n(a, b, c, d) = [int(x) for x in input().split()]\nif a * d / c > b:\n\tt1 = b * c\n\tt2 = a * d\n\tt3 = a * d - t1\n\tif t3 == 0:\n\t\tprint('0/1')\n\telse:\n\t\tg1 = math.gcd(t3, t2)\n\t\tt3 //= g1\n\t\tt2 //= g1\n\t\tprint(t3, '/', t2, sep='')\nelse:\n\tt1 = a * d\n\tt2 = b * c\n\tt3 = b * c - t1\n\tif t3 == 0:\n\t\tprint('0/1')\n\telse:\n\t\tg1 = math.gcd(t3, t2)\n\t\tt3 //= g1\n\t\tt2 //= g1\n\t\tprint(t3, '/', t2, sep='')\n", "def gcd(a, b):\n\tif a < b:\n\t\t(a, b) = (b, a)\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n(a, b, c, d) = map(int, input().split())\nif a / c == b / d:\n\tprint(0, end='')\n\tprint('/', end='')\n\tprint(1)\nelif a / c > b / d:\n\torignal_c = c\n\tnum = a * d - c * b\n\tdeno = a * d\n\tg = gcd(num, deno)\n\tnum //= g\n\tdeno //= g\n\tprint(num, end='')\n\tprint('/', end='')\n\tprint(deno)\nelse:\n\tnum = b * c - a * d\n\tdeno = b * c\n\tg = gcd(num, deno)\n\tnum //= g\n\tdeno //= g\n\tprint(num, end='')\n\tprint('/', end='')\n\tprint(deno)\n", "import sys\nfrom fractions import gcd\nmy_file = sys.stdin\nline = [int(i) for i in my_file.readline().split()]\n(a, b, c, d) = (line[0], line[1], line[2], line[3])\nif a / b < c / d:\n\tN = b * c - a * d\n\tD = b * c\nelse:\n\tN = a * d - b * c\n\tD = a * d\ndec = gcd(N, D)\nprint(N // dec, end='/')\nprint(D // dec)\n", "from math import *\n(x, y, a, b) = map(int, input().split())\nif b / a * x > y:\n\tp = a * y * y\n\tq = b * x * y\nelse:\n\tp = b * x * x\n\tq = a * x * y\nk = gcd(p, q)\np //= k\nq //= k\np = q - p\nprint(str(p) + '/' + str(q))\n", "def gcd(a, b):\n\twhile a % b != 0:\n\t\t(a, b) = (b, a % b)\n\treturn b\nl = input().split(' ')\n(a, b, c, d) = (int(l[0]), int(l[1]), int(l[2]), int(l[3]))\nif a * d > b * c:\n\tp = a * d - b * c\n\tq = a * d\nelse:\n\tp = b * c - a * d\n\tq = b * c\ne = gcd(p, q)\np //= e\nq //= e\nprint(str(p) + '/' + str(q))\n", "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn gcd(b, a % b)\ns = input().split(' ')\na = int(s[0])\nb = int(s[1])\nc = int(s[2])\nd = int(s[3])\nr1 = a / b\nr2 = c / d\nif r1 < r2:\n\tnom = b * c - d * a\n\tden = c * b\n\tg = gcd(nom, den)\n\tnom = nom // g\n\tden = den // g\n\tprint(str(nom) + '/' + str(den))\nelse:\n\tnom = a * d - c * b\n\tden = d * a\n\tg = gcd(nom, den)\n\tnom = nom // g\n\tden = den // g\n\tprint(str(nom) + '/' + str(den))\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nh = a * d / c\nv = b * c / d\nif v > a:\n\tv = 0\nif h > b:\n\th = 0\nif h != 0:\n\tans = str(Fraction((b - h) / b).limit_denominator())\nelse:\n\tans = str(Fraction((a - v) / a).limit_denominator())\nif ans == '0':\n\tprint('0/1')\nelse:\n\tprint(ans)\n", "import math\n\ndef solve(a, b, c, d):\n\tif a == c and c == d:\n\t\treturn '0/1'\n\tif a < c or b < d:\n\t\tx1 = c / a\n\t\tx2 = d / b\n\t\tif x1 > x2:\n\t\t\tnum = int(b * c - d * a)\n\t\t\tden = c * b\n\t\telse:\n\t\t\tnum = int(a * d - b * c)\n\t\t\tden = d * a\n\t\ti = 2\n\t\twhile i <= num:\n\t\t\tif num % i == 0 and den % i == 0:\n\t\t\t\tnum = num // i\n\t\t\t\tden = den // i\n\t\t\telse:\n\t\t\t\ti += 1\n\t\tif num == 0:\n\t\t\tden = 1\n\t\treturn str(num) + '/' + str(den)\n\tx1 = a / c\n\tx2 = b / d\n\tif x2 < x1:\n\t\tif int(x2) == x2 or int(c * x2) == c * x2:\n\t\t\tnum = int(a - x2 * c)\n\t\t\tden = a\n\t\telse:\n\t\t\tnum = a * d - c * b\n\t\t\tden = a * d\n\telif int(x1) == x1 or int(x1 * d) == x1 * d:\n\t\tnum = int(b - x1 * d)\n\t\tden = b\n\telse:\n\t\tnum = c * b - a * d\n\t\tden = c * b\n\tup = math.ceil(math.sqrt(num))\n\ti = 2\n\twhile i <= num:\n\t\tif num % i == 0 and den % i == 0:\n\t\t\tnum = num // i\n\t\t\tden = den // i\n\t\telse:\n\t\t\ti += 1\n\tif num == 0:\n\t\tden = 1\n\treturn str(num) + '/' + str(den)\n(a, b, c, d) = map(int, input().split())\nprint(solve(a, b, c, d))\n", "from fractions import Fraction\nwhile 1:\n\ttry:\n\t\t(a, b, c, d) = map(int, input().split())\n\t\tif a / b < c / d:\n\t\t\tratio = 0\n\t\telif a / b == c / d:\n\t\t\tratio = -1\n\t\telse:\n\t\t\tratio = 1\n\t\tif ratio == 0:\n\t\t\tf = Fraction(b * c - a * d, b * c)\n\t\t\tprint('%s' % f)\n\t\telif ratio == 1:\n\t\t\tf = Fraction(a * d - b * c, a * d)\n\t\t\tprint('%s' % f)\n\t\telse:\n\t\t\tprint('0/1')\n\texcept EOFError:\n\t\tbreak\n", "import sys\n\ndef gcd(a, b):\n\tif b < 0.001:\n\t\treturn a\n\treturn gcd(b, a % b)\n(a, b, c, d) = [int(i) for i in sys.stdin.readline().split()]\nx = a / c\ny = b / d\nf = max(x if x * d <= b else -1, y if y * c <= a else -1)\ncommon = gcd(f * f * c * d, a * b)\ndown = a * b / common\nup = down - f * f * c * d / common\nprint('{}/{}'.format(int(up), int(down)))\n", "(a, b, c, d) = [int(x) for x in input().split()]\nresult = max((b * c - a * d) * a * d, (a * d - b * c) * b * c)\n(m, n) = (result, c * d * a * b)\nwhile n != 0:\n\t(m, n) = (n, m % n)\nprint('{}/{}'.format(result // m, c * d * a * b // m))\n", "from fractions import gcd\n\ndef main():\n\t(a, b, c, d) = map(int, input().split())\n\t(ratiom, ratios) = (a / b, c / d)\n\tif ratiom == ratios:\n\t\t(empty, total) = (0, 1)\n\telse:\n\t\tlcm = lambda x, y: x * y // gcd(x, y)\n\t\tif ratiom > ratios:\n\t\t\twidth = lcm(a, c)\n\t\t\ttotal = width // c * d\n\t\t\tempty = total - width // a * b\n\t\telse:\n\t\t\theight = lcm(b, d)\n\t\t\ttotal = height // d * c\n\t\t\tempty = total - height // b * a\n\t\tg = gcd(total, empty)\n\t\ttotal //= g\n\t\tempty //= g\n\tprint('{}/{}'.format(empty, total))\nmain()\n", "import math\n(a, b, c, d) = map(int, input().split())\n\ndef gcd(a, b):\n\tm = a * b\n\twhile b:\n\t\t(a, b) = (b, a % b)\n\treturn m // a\nq = a\nw = b\ne = c\nr = d\nc1 = gcd(a, c)\nmbf = c1 / a\nb = b * mbf\nmdf = c1 / c\nd = d * mdf\nup1 = b - d\ndo1 = b\nch1 = up1 / do1\na = q\nb = w\nc = e\nd = r\nc2 = gcd(b, d)\nmaf = c2 / b\na = a * maf\nmdf = c2 / d\nc = c * mdf\nup2 = a - c\ndo2 = a\nch2 = up2 / do2\nif ch1 < 0:\n\tch1 = 999999999999999\nif ch2 < 0:\n\tch2 = 999999999999999\nif up1 == 0:\n\tdo1 = 1\nif up2 == 0:\n\tdo2 = 1\nif ch1 < ch2:\n\ti = 2\n\twhile i <= int(min(up1, do1)) + 1:\n\t\tif up1 % i == 0 and do1 % i == 0:\n\t\t\tup1 = up1 // i\n\t\t\tdo1 = do1 // i\n\t\telse:\n\t\t\ti = i + 1\n\tprint(int(up1), '/', int(do1), sep='')\nelse:\n\ti = 2\n\twhile i <= int(min(up2, do2)) + 1:\n\t\tif up2 % i == 0 and do2 % i == 0:\n\t\t\tup2 = up2 // i\n\t\t\tdo2 = do2 // i\n\t\telse:\n\t\t\ti = i + 1\n\tprint(int(up2), '/', int(do2), sep='')\n", "import math\n(a, b, c, d) = map(int, input().split())\nx = 0\ny = 0\nif a / b < c / d:\n\tx = b * c - a * d\n\ty = b * c\n\tz = math.gcd(x, y)\n\tx = x // z\n\ty = y // z\n\tprint(str(x) + '/' + str(y))\nelif a / b > c / d:\n\tx = a * d - b * c\n\ty = a * d\n\tz = math.gcd(x, y)\n\tx = x // z\n\ty = y // z\n\tprint(str(x) + '/' + str(y))\nelse:\n\tprint('0/1')\n", "def gcd(a, b):\n\twhile a != b:\n\t\tif a > b:\n\t\t\ta = a - b\n\t\telse:\n\t\t\tb = b - a\n\tprint(m // a, '/', n // a, sep='')\n(a, b, c, d) = map(int, input().split())\nm = 1\nn = 1\nif a == b:\n\tif c == d:\n\t\tprint(0, '/', 1, sep='')\n\telif c > d:\n\t\tm = b * c - a * d\n\t\tn = c * b\n\t\tgcd(m, n)\n\telse:\n\t\tm = a * d - c * b\n\t\tn = a * d\n\t\tgcd(m, n)\nelif c / d == a / b:\n\tprint(0, '/', 1)\nelif c / d > a / b:\n\tm = b * c - a * d\n\tn = c * b\n\tgcd(m, n)\nelse:\n\tm = a * d - c * b\n\tn = a * d\n\tgcd(m, n)\n", "from fractions import Fraction, gcd\n(a, b, c, d) = [int(x) for x in input().split()]\nif a * d > b * c:\n\tnum = a * d - b * c\n\tdenom = a * d\nelse:\n\tnum = b * c - a * d\n\tdenom = b * c\ndiv = gcd(num, denom)\nprint('%d/%d' % (num // div, denom // div))\n", "def gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\treturn gcd(b % a, a)\n(a, b, c, d) = map(int, input().split())\ns = 0\nif a / b == c / d:\n\tprint('0/1')\nelif a / b > c / d:\n\ts = a * d - b * c\n\te = a * d\nelse:\n\ts = b * c - a * d\n\te = b * c\nif s:\n\tfor i in range(2, 10 ** 6):\n\t\tif s % i == 0 and e % i == 0:\n\t\t\ts /= i\n\t\t\te /= i\n\t\t\twhile s % i == 0 and e % i == 0:\n\t\t\t\ts /= i\n\t\t\t\te /= i\n\t\tif s == 1:\n\t\t\tbreak\n\tst = str(int(s)) + '/' + str(int(e))\n\tprint(st)\n", "from fractions import Fraction\n\ndef hcf(a, b):\n\tif b == 0:\n\t\treturn a\n\telse:\n\t\treturn hcf(b, a % b)\n(a, b, c, d) = map(int, input().split())\nac = a / c\nbd = b / d\nif ac <= bd:\n\tmmin = a\n\tfmax = c\n\tnum = a * b * fmax ** 2 - mmin ** 2 * c * d\n\tden = a * b * fmax ** 2\n\th = hcf(num, den)\n\tprint(int(num / h), end='/')\n\tprint(int(den / h))\nelse:\n\tmmin = b\n\tfmax = d\n\tnum = a * b * fmax ** 2 - mmin ** 2 * c * d\n\tden = a * b * fmax ** 2\n\th = hcf(num, den)\n\tprint(int(num / h), end='/')\n\tprint(int(den / h))\n", "def gcd(x, y):\n\twhile x != 0:\n\t\t(x, y) = (y % x, x)\n\treturn y\n\ndef main():\n\t(a, b, c, d) = [int(item) for item in input().split()]\n\tk1 = float(a) / float(b)\n\tk2 = float(c) / float(d)\n\tp = 0\n\tq = 1\n\tg = 0\n\tif k1 > k2:\n\t\tq = a * d\n\t\tp = q - b * c\n\t\tg = gcd(p, q)\n\telif k1 < k2:\n\t\tq = b * c\n\t\tp = q - a * d\n\t\tg = gcd(p, q)\n\tif g > 1:\n\t\tp = int(p / g)\n\t\tq = int(q / g)\n\tprint('{}/{}'.format(p, q))\nmain()\n", "import fractions\n(a, b, c, d) = list(map(int, input().split()))\np = max(a * d, b * c) - min(a * d, b * c)\nq = max(a * d, b * c)\nx = fractions.gcd(p, q)\nprint(str(p // x) + '/' + str(q // x))\n", "import sys\nimport heapq\nfrom math import *\nfrom collections import defaultdict as dd\nfrom collections import deque\nfrom collections import Counter as c\nfrom itertools import combinations as comb\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nmod = pow(10, 9) + 7\nmod2 = 998244353\n\ndef data():\n\treturn sys.stdin.readline().strip()\n\ndef out(var):\n\tsys.stdout.write(var)\n\ndef l():\n\treturn list(map(int, data().split()))\n\ndef sl():\n\treturn list(map(str, data().split()))\n\ndef sp():\n\treturn map(int, data().split())\n\ndef ssp():\n\treturn map(str, data().split())\n\ndef l1d(n, val=0):\n\treturn [val for i in range(n)]\n\ndef l2d(n, m, val=0):\n\treturn [[val for i in range(n)] for j in range(m)]\n\ndef first():\n\tglobal a, b, e, d\n\t(div, mul) = (e, a)\n\t(a1, a2) = (e * mul, a * mul)\n\treturn (a * b * e - d * a * a, div)\n\ndef second():\n\tglobal a, b, e, d\n\t(div, mul) = (d, b)\n\t(a1, a2) = (e * mul, d * mul)\n\treturn (d * a * b - e * b * b, div)\n(a, b, e, d) = sp()\nt1 = first()\nt2 = second()\nif t1[0] / t1[1] < t2[0] / t2[1]:\n\t(diff, area) = (int(t1[0]), int(a * b * t1[1]))\nelse:\n\t(diff, area) = (int(t2[0]), int(a * b * t2[1]))\nif t2[0] / t2[1] < 0:\n\t(diff, area) = (int(t1[0]), int(a * b * t1[1]))\nelif t1[0] / t1[1] < 0:\n\t(diff, area) = (int(t2[0]), int(a * b * t2[1]))\ng = gcd(diff, area)\nout(str(diff // g) + '/' + str(area // g))\n", "from fractions import Fraction as frac\n(a, b, p, q) = [int(x) for x in input().split()]\nif a / b == p / q:\n\tprint('0/1')\nelif a / b < p / q:\n\tx = p * b - a * q\n\ty = p * b\n\tprint(frac(x, y))\nelse:\n\tx = a * q - p * b\n\ty = a * q\n\tprint(frac(x, y))\n", "import math\nfrom fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nx = a * c // math.gcd(a, c)\ny = b * d // math.gcd(b, d)\nans1 = (abs(b * (x // a) - d * (x // c)), max(b * x // a, d * x // c))\nans2 = (abs(a * (y // b) - c * (y // d)), max(a * y // b, c * y // d))\nf1 = Fraction(ans1[0], ans1[1])\nf2 = Fraction(ans2[0], ans2[1])\nif f1 > f2:\n\tprint(f1.numerator, end='')\n\tprint('/', end='')\n\tprint(f1.denominator)\nelse:\n\tprint(f2.numerator, end='')\n\tprint('/', end='')\n\tprint(f2.denominator)\n", "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\nimport copy\nimport time\nstarttime = time.time()\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\n\ndef data():\n\treturn sys.stdin.readline().strip()\n\ndef out(*var, end='\\n'):\n\tsys.stdout.write(' '.join(map(str, var)) + end)\n\ndef L():\n\treturn list(sp())\n\ndef sl():\n\treturn list(ssp())\n\ndef sp():\n\treturn map(int, data().split())\n\ndef ssp():\n\treturn map(str, data().split())\n\ndef l1d(n, val=0):\n\treturn [val for i in range(n)]\n\ndef l2d(n, m, val=0):\n\treturn [l1d(n, val) for j in range(m)]\ntry:\n\tsys.setrecursionlimit(int(pow(10, 6)))\n\tsys.stdin = open('input.txt', 'r')\nexcept:\n\tpass\nfrom math import gcd\n(a, b, c, d) = map(int, input().split())\narea = a * b\nx_num = a * d\nx_den = c\nx = x_num / x_den\narea1 = x * a\ny_num = b * c\ny_den = d\ny = y_num / y_den\narea2 = y * b\nif area2 > area or y > a:\n\tarea2 = 0\nif area1 > area or x > b:\n\tarea1 = 0\nif area1 >= area2:\n\tleft_num = b * x_den - x_num\n\tp_num = left_num * a\n\tp_den = x_den\n\thm_num = p_num\n\thm_den = p_den * area\n\tz = gcd(hm_num, hm_den)\n\tans_num = hm_num // z\n\tans_den = hm_den // z\n\tans = str(ans_num) + '/' + str(ans_den)\nif area1 <= area2:\n\tleft_num = a * y_den - y_num\n\tp_num = left_num * b\n\tp_den = y_den\n\thm_num = p_num\n\thm_den = p_den * area\n\tz = gcd(hm_num, hm_den)\n\tans_num = hm_num // z\n\tans_den = hm_den // z\n\tans = str(ans_num) + '/' + str(ans_den)\nprint(ans)\nendtime = time.time()\n", "def gcd(a, b):\n\twhile b:\n\t\ta %= b\n\t\t(a, b) = (b, a)\n\treturn a\n(a, b, c, d) = map(int, input().split())\nif a / b < c / d:\n\td1 = b * c - a * d\n\te = b * c\n\tf = gcd(d1, e)\n\tprint(str(d1 // f) + '/' + str(e // f))\nelif a / b > c / d:\n\td1 = a * d - b * c\n\te = a * d\n\tf = gcd(d1, e)\n\tprint(str(d1 // f) + '/' + str(e // f))\nelse:\n\tprint('0/1')\n", "def scan(type):\n\treturn list(map(type, input().split()))\n\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n\ndef lcm(a, b):\n\treturn a * b // gcd(a, b)\n(a, b, c, d) = scan(int)\nnum = den = ans = 100000000\nk = lcm(a, c)\n_a = a * k // a\n_b = b * k // a\n_c = c * k // c\n_d = d * k // c\nif _a >= _c and _b >= _d:\n\t_num = _a * _b - _c * _d\n\t_den = _a * _b\n\t_ans = _num / _den\n\tif _ans < ans:\n\t\tans = _ans\n\t\tnum = _num\n\t\tden = _den\nk = lcm(b, d)\n_a = a * k // b\n_b = b * k // b\n_c = c * k // d\n_d = d * k // d\nif _a >= _c and _b >= _d:\n\t_num = _a * _b - _c * _d\n\t_den = _a * _b\n\t_ans = _num / _den\n\tif _ans < ans:\n\t\tans = _ans\n\t\tnum = _num\n\t\tden = _den\nk = gcd(num, den)\nnum /= k\nden /= k\nprint('%d/%d' % (num, den))\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\n(m1, m2, m3, m4) = (99999999, 99999999, 999999, 99999)\nif c < d and c * (b / a) >= d:\n\ttemp = Fraction(c * b, a)\n\tx = temp - d\n\tm1 = Fraction(x * c, c * temp)\nelif d < c and d * (a / b) >= c:\n\ttemp = Fraction(d * a, b)\n\tx = temp - c\n\tm2 = Fraction(x * d, d * temp)\nelif c > d and c * (b / a) >= d:\n\ttemp = Fraction(c * b, a)\n\tx = temp - d\n\tm3 = Fraction(x * c, c * temp)\nelse:\n\ttemp = Fraction(d * a, b)\n\tx = temp - c\n\tm4 = Fraction(x * d, d * temp)\ns = str(min(m1, m2, m3, m4))\ng = s.split('/')\nif len(g) == 2:\n\tprint(s)\nelse:\n\tprint(s + '/' + '1')\n", "(a, b, c, d) = [int(j) for j in input().split()]\n\ndef gcd(a, b):\n\tc = a % b\n\twhile c != 0:\n\t\ta = b\n\t\tb = c\n\t\tc = a % b\n\treturn b\n(ra, rb) = (0, 0)\nif c * b >= a * d:\n\tra = b * c - a * d\n\trb = b * c\nelse:\n\tra = a * d - b * c\n\trb = a * d\ncm = gcd(ra, rb)\nprint('{}/{}'.format(int(ra / cm), int(rb / cm)))\n", "def gcd(a, b):\n\tif a % b == 0:\n\t\treturn b\n\treturn gcd(b, a % b)\n\ndef solve(a, b, p, q):\n\tc = a * p / gcd(a, p)\n\tb1 = b * c / a\n\tq1 = q * c / p\n\tif b1 >= q1:\n\t\tif b1 == q1:\n\t\t\tprint('0/1')\n\t\telse:\n\t\t\td = gcd(b1 - q1, b1)\n\t\t\tprint(str(int((b1 - q1) / d)) + '/' + str(int(b1 / d)))\n\t\treturn True\n\treturn False\n\ndef __starting_point():\n\t(a, b, p, q) = map(int, input().split())\n\tif not solve(a, b, p, q):\n\t\tsolve(b, a, q, p)\n__starting_point()\n", "from fractions import Fraction\n\ndef main():\n\t(a, b, c, d) = map(int, input().split())\n\tif Fraction(a, b) == Fraction(c, d):\n\t\tprint('0/1')\n\t\treturn\n\tw = (b - d * Fraction(a, c)) / b\n\th = (a - c * Fraction(b, d)) / a\n\tif w < 0:\n\t\tw = float('infinity')\n\tif h < 0:\n\t\th = float('infinity')\n\tans = min(w, h)\n\tprint(ans)\nmain()\n", "(a, b, c, d) = list(map(int, input().split()))\n\ndef largest_div(n, m):\n\twhile m > 0:\n\t\trest = n % m\n\t\tn = m\n\t\tm = rest\n\treturn n\nif a / b == c / d:\n\tprint('0/1')\nelse:\n\tif a / b > c / d:\n\t\tf_new_width = c * b\n\t\tf_upper = d * a - f_new_width\n\t\tf_lower = d * a\n\telse:\n\t\tf_new_height = d * a\n\t\tf_upper = c * b - f_new_height\n\t\tf_lower = c * b\n\tdiv = largest_div(f_upper, f_lower)\n\tprint('/'.join((str(int(f_upper / div)), str(int(f_lower / div)))))\n", "def g(e, f):\n\twhile f != 0:\n\t\t(e, f) = (f, e % f)\n\treturn e\n(a, b, c, d) = map(int, input().split())\nif a / b <= c / d:\n\tout1 = b * c - a * d\n\tout2 = b * c\n\tprint(int(out1 / g(out1, out2)), '/', int(out2 / g(out1, out2)), sep='')\nelse:\n\tout1 = a * d - b * c\n\tout2 = a * d\n\tprint(int(out1 / g(out1, out2)), '/', int(out2 / g(out1, out2)), sep='')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\ng = Fraction(b * c) / Fraction(a * d)\nif g > 1:\n\tg = Fraction(1 / g)\nl = 1 - g\nif l == 0:\n\tprint('0/1')\nelif l == 1:\n\tprint('1/1')\nelse:\n\tprint(l)\n", "from sys import stdin\nfrom fractions import Fraction\n(a, b, c, d) = map(int, input().split())\ncd = Fraction(c, d)\nab = Fraction(a, b)\nf1 = Fraction(1, 1)\nif cd < ab:\n\tprint(f1 - Fraction(c * b, a * d))\nelif cd > ab:\n\tprint(f1 - Fraction(a * d, c * b))\nelse:\n\tprint('0/1')\n", "import math as m\n(a, b, c, d) = input().split(' ')\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\nif a * d > b * c:\n\th = m.gcd(a * d - b * c, a * d)\n\tk = int((a * d - b * c) / h)\n\td = int(a * d / h)\n\tprint(k, end='')\n\tprint('/', end='')\n\tprint(d, end='')\nelif a * d <= b * c:\n\th = m.gcd(c * b - a * d, b * c)\n\tk = int((c * b - a * d) / h)\n\td = int(b * c / h)\n\tprint(k, end='')\n\tprint('/', end='')\n\tprint(d, end='')\n", "(a, b, c, d) = map(int, input().split())\n\ndef gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\treturn gcd(b % a, a)\n\ndef solv(a, b):\n\tgc = gcd(a, b)\n\tprint('%d/%d' % (a // gc, b // gc))\nif a * d < b * c:\n\tsolv(b * c - a * d, b * c)\nelse:\n\tsolv(a * d - b * c, a * d)\n", "def gcd(a, b):\n\tif a < 0.001:\n\t\treturn b\n\treturn gcd(b % a, a)\n(a, b, c, d) = [int(x) for x in input().split()]\nwidthRatio = a / c\nheightRatio = b / d\nbestratio = min(widthRatio, heightRatio)\nnewImageHeight = bestratio * d\nnewImageWidth = bestratio * c\nmonitorSurface = a * b\nimageSurface = newImageWidth * newImageHeight\ng = gcd(imageSurface, monitorSurface)\nimageSurface /= g\nmonitorSurface /= g\nempty = monitorSurface - imageSurface\nprint(f'{int(empty)}/{int(monitorSurface)}')\n", "3\nimport sys\nfrom fractions import Fraction\n(a, b, c, d) = list(map(int, sys.stdin.readline().strip().split()))\nd2 = Fraction(d * a, c)\nans = None\nif d2 <= Fraction(b):\n\tans = (Fraction(b) - d2) / Fraction(b)\nelse:\n\tc2 = Fraction(c * b, d)\n\tans = (Fraction(a) - c2) / Fraction(a)\nif ans.denominator == 1:\n\tprint('%d/1' % ans.numerator)\nelse:\n\tprint(ans)\n", "import sys\n\ndef gcd(a, b):\n\twhile b:\n\t\t(a, b) = (b, a % b)\n\treturn a\n\nclass Fraction:\n\n\tdef __init__(self, p=0, q=1, reduced=True):\n\t\tif type(p) == int:\n\t\t\tself.p = p\n\t\t\tif type(q) == int:\n\t\t\t\tself.q = q\n\t\telif type(p) == Fraction:\n\t\t\tself.p = p.p\n\t\t\tself.q = p.q\n\t\telse:\n\t\t\ti = p.find(' ')\n\t\t\tif i == -1:\n\t\t\t\ti = p.find('/')\n\t\t\tif i == -1:\n\t\t\t\tself.p = int(p)\n\t\t\t\tself.q = 1\n\t\t\telse:\n\t\t\t\tself.p = int(p[:i])\n\t\t\t\tself.q = int(p[i + 1:])\n\t\tif reduced:\n\t\t\tself.reduce()\n\n\tdef reduce(self):\n\t\tg = gcd(self.p, self.q)\n\t\tself.p //= g\n\t\tself.q //= g\n\n\tdef __str__(self):\n\t\tif self.q == 1:\n\t\t\treturn str(self.p)\n\t\telse:\n\t\t\treturn str(self.p) + '/' + str(self.q)\n\n\tdef __lt__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == float or type(other) == int:\n\t\t\treturn self.p < other * self.q\n\t\telse:\n\t\t\tother.reduce()\n\t\t\treturn self.p * other.q < self.q * other.p\n\n\tdef __le__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == float or type(other) == int:\n\t\t\treturn self.p <= other * self.q\n\t\telse:\n\t\t\tother.reduce()\n\t\t\treturn self.p * other.q <= self.q * other.p\n\n\tdef __gt__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == float or type(other) == int:\n\t\t\treturn self.p > other * self.q\n\t\telse:\n\t\t\tother.reduce()\n\t\t\treturn self.p * other.q > self.q * other.p\n\n\tdef __ge__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == float or type(other) == int:\n\t\t\treturn self.p >= other * self.q\n\t\telse:\n\t\t\tother.reduce()\n\t\t\treturn self.p * other.q >= self.q * other.p\n\n\tdef __eq__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == float or type(other) == int:\n\t\t\treturn self.p == other * self.q\n\t\telse:\n\t\t\tother.reduce()\n\t\t\treturn self.p * other.q == self.q * other.p\n\n\tdef __ne__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == float or type(other) == int:\n\t\t\treturn self.p != other * self.q\n\t\telse:\n\t\t\tother.reduce()\n\t\t\treturn self.p * other.q != self.q * other.p\n\n\tdef __mul__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.p * other, self.q)\n\t\telif type(other) == float:\n\t\t\treturn self.p * other / self.q\n\t\telse:\n\t\t\treturn Fraction(self.p * other.p, self.q * other.q)\n\n\tdef __rmul__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.p * other, self.q)\n\t\telif type(other) == float:\n\t\t\treturn self.p * other / self.q\n\t\telse:\n\t\t\treturn Fraction(self.p * other.p, self.q * other.q)\n\n\tdef __imul__(self, other):\n\t\tself = self * other\n\t\treturn self\n\n\tdef __truediv__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.p, self.q * other)\n\t\telif type(other) == float:\n\t\t\treturn self.p / self.q / other\n\t\telse:\n\t\t\treturn Fraction(self.p * other.q, self.q * other.p)\n\n\tdef __rtruediv__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.q * other, self.p)\n\t\telif type(other) == float:\n\t\t\treturn other * self.q / self.p\n\t\telse:\n\t\t\treturn Fraction(self.q * other.p, self.p * other.q)\n\n\tdef __itruediv__(self, other):\n\t\tself = self / other\n\t\treturn self\n\n\tdef __pow__(self, other):\n\t\tif type(other) == int:\n\t\t\tif other >= 0:\n\t\t\t\treturn Fraction(self.p ** other, self.q ** other, False)\n\t\t\telse:\n\t\t\t\treturn Fraction(self.q ** (-other), self.p ** (-other), False)\n\t\telif type(other) == float:\n\t\t\treturn (self.p / self.q) ** other\n\t\telse:\n\t\t\treturn (self.p / self.q) ** (other.p / other.q)\n\n\tdef __rpow__(self, other):\n\t\tif type(other) == int or type(other) == float:\n\t\t\treturn other ** (self.p / self.q)\n\t\telse:\n\t\t\treturn (other.p / other.q) ** (self.p / self.q)\n\n\tdef __ipow__(self, other):\n\t\tself = self ** other\n\t\treturn self\n\n\tdef __add__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.p + self.q * other, self.q)\n\t\telif type(other) == float:\n\t\t\treturn self.p / self.q + other\n\t\telse:\n\t\t\treturn Fraction(self.p * other.q + self.q * other.p, self.q * other.q)\n\n\tdef __radd__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.p + self.q * other, self.q)\n\t\telif type(other) == float:\n\t\t\treturn self.p / self.q + other\n\t\telse:\n\t\t\treturn Fraction(self.p * other.q + self.q * other.p, self.q * other.q)\n\n\tdef __iadd__(self, other):\n\t\tself.reduce()\n\t\tself = self + other\n\t\treturn self\n\n\tdef __sub__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.p - self.q * other, self.q)\n\t\telif type(other) == float:\n\t\t\treturn self.p / self.q - other\n\t\telse:\n\t\t\treturn Fraction(self.p * other.q - self.q * other.p, self.q * other.q)\n\n\tdef __rsub__(self, other):\n\t\tself.reduce()\n\t\tif type(other) == int:\n\t\t\treturn Fraction(self.q * other - self.p, self.q)\n\t\telif type(other) == float:\n\t\t\treturn other - self.p / self.q\n\t\telse:\n\t\t\treturn Fraction(self.q * other.p - self.p * other.q, self.q * other.q)\n\n\tdef __pos__(self):\n\t\treturn Fraction(+self.p, +self.q)\n\n\tdef __neg__(self):\n\t\treturn Fraction(-self.p, self.q)\n\n\tdef __abs__(self):\n\t\tif self.p < 0:\n\t\t\treturn -self\n\t\telse:\n\t\t\treturn self\n\n\tdef __int__(self):\n\t\treturn self.p // self.q\n\n\tdef __float__(self):\n\t\treturn self.p / self.q\n\n\tdef __round__(self, digits=0):\n\t\treturn round(float(self), digits)\n(a, b, c, d) = map(int, input().split())\nproduct = a * c\nB1 = b * c\nB2 = a * d\nif B1 > B2:\n\t(B1, B2) = (B2, B1)\nans = Fraction(B2 - B1, B2)\nans.reduce()\nif ans != 0:\n\tprint(abs(ans))\nelse:\n\tprint('0/1')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nad = a * d\nbc = b * c\nif ad >= bc:\n\tf = Fraction(ad - bc, ad)\nelse:\n\tf = Fraction(bc - ad, bc)\nprint('{}/{}'.format(f.numerator, f.denominator))\n", "import sys\ninput = sys.stdin.readline\nread_tuple = lambda _type: map(_type, input().split(' '))\nfrom fractions import Fraction as frac\n\ndef solve():\n\t(a, b, c, d) = read_tuple(int)\n\tS_monitor = a * b\n\tS1 = b * frac(c * b, d)\n\tS2 = a * frac(d * a, c)\n\t(ans1, ans2) = ((S_monitor - S1) / S_monitor, (S_monitor - S2) / S_monitor)\n\tans = None\n\tif ans1 < 0:\n\t\tans = ans2\n\telif ans2 < 0:\n\t\tans = ans1\n\telse:\n\t\tans = min(ans1, ans2)\n\tif ans:\n\t\tprint(ans)\n\telse:\n\t\tprint('0/1')\nsolve()\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nz1 = Fraction(Fraction(a, b), Fraction(c, d))\nz2 = Fraction(Fraction(c, d), Fraction(a, b))\nif Fraction(1, 1) - z1 == 0:\n\tprint('0/1')\nelse:\n\tx = Fraction(1, 1) - z1\n\tif x > 0 and x < 1:\n\t\tprint(x)\n\telse:\n\t\tprint(Fraction(1, 1) - z2)\n", "(a, b, c, d) = [int(x) for x in input().split(' ')]\nif a / b < c / d:\n\tx = b * c - a * d\n\ty = b * c\n\tfor i in range(2, min(x, y) + 1):\n\t\twhile x % i == 0 and y % i == 0:\n\t\t\tx //= i\n\t\t\ty //= i\n\tprint(x, '/', y, sep='')\nelif a / b > c / d:\n\tx = a * d - b * c\n\ty = a * d\n\tfor i in range(2, min(x, y) + 1):\n\t\twhile x % i == 0 and y % i == 0:\n\t\t\tx //= i\n\t\t\ty //= i\n\tprint(x, '/', y, sep='')\nelse:\n\tprint('0/1')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nif a / c <= b / d:\n\tres = Fraction(b * c - a * d, b * c)\nelse:\n\tres = Fraction(a * d - b * c, a * d)\nprint('{0}/{1}'.format(res.numerator, res.denominator))\n", "import math\n\ndef possible_check(a, b, c, d):\n\tif a >= c and b >= d:\n\t\treturn 1\n\telse:\n\t\treturn 0\n\ndef find_common_divisor(a, b):\n\tif a == 0:\n\t\treturn (0, 1)\n\tgcd = math.gcd(a, b)\n\treturn (a // gcd, b // gcd)\n(a, b, c, d) = map(int, input().split())\nmul1 = a\ndiv1 = c\nmul2 = b\ndiv2 = d\nans = 100000000\nflag = 0\nif possible_check(a, b, a, d * mul1 / div1):\n\tarea = 1 - d * mul1 / (div1 * b)\n\tif area < ans:\n\t\tans = area\n\t\tflag = 1\nif possible_check(a, b, c * mul2 / div2, b):\n\tarea = 1 - c * mul2 / (div2 * a)\n\tif area < ans:\n\t\tans = area\n\t\tflag = 2\nif flag == 1:\n\t(num, demo) = find_common_divisor(div1 * b - d * mul1, div1 * b)\n\tprint(num, '/', demo, sep='')\nelse:\n\t(num, demo) = find_common_divisor(div2 * a - c * mul2, div2 * a)\n\tprint(num, '/', demo, sep='')\n", "import math\nL = lambda : list(map(int, input().split()))\nM = lambda : map(int, input().split())\nI = lambda : int(input())\nIN = lambda : input()\n\ndef s(a):\n\tprint(''.join(list(map(str, a))))\n(a, b, c, d) = M()\nnum = abs(b * c - a * d)\nden = max(b * c, a * d)\nx = math.gcd(num, den)\nnum = num // x\nden = den // x\nprint(str(num) + '/' + str(den))\n", "def gcd(a, b):\n\tif a == 0:\n\t\treturn b\n\treturn gcd(b % a, a)\n(a, b, c, d) = [int(x) for x in input().split()]\ntop = abs(a * d - b * c)\nbottom = max(a * d, b * c)\nif top == 0:\n\tprint('0/1')\nelse:\n\tg = gcd(top, bottom)\n\ttop //= g\n\tbottom //= g\n\tprint(f'{top}/{bottom}')\n", "(a, b, c, d) = map(int, input().split())\n\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\tif b == 1:\n\t\treturn 1\n\treturn gcd(b, a % b)\nif c * b < a * d:\n\t(a, b) = (b, a)\n\t(c, d) = (d, c)\none = a * d\ntwo = b * c\ngc = gcd(two, one)\nprint((two - one) // gc, '/', two // gc, sep='')\n", "(a, b, c, d) = map(int, input().split())\nb *= c\nd *= a\na = abs(b - d)\nb = max(b, d)\nimport math\ndiv = math.gcd(a, b)\nprint(a // div, '/', b // div, sep='')\n", "from math import *\n\ndef GCD(a, b):\n\twhile b:\n\t\ta %= b\n\t\t(a, b) = (b, a)\n\treturn a\n(a, b, c, d) = map(int, input().split())\n(C, D) = (min(a * d, b * c), max(a * d, b * c))\nC = D - C\nG = GCD(C, D)\nC = C // G\nD = D // G\nprint(str(C) + '/' + str(D))\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nr = min(c / a, d / b)\na = a * r\nb = b * r\nif c * d - a * b == 0:\n\tprint('0/1')\nelse:\n\tprint(Fraction((c * d - a * b) / (c * d)).limit_denominator())\n", "import math\nNO_OF_CHARS = 256\n\ndef inp():\n\treturn int(input())\n\ndef inlt():\n\treturn list(map(int, input().split()))\n\ndef insr():\n\ts = input()\n\treturn list(s[:len(s) - 1])\n\ndef invr():\n\treturn map(int, input().split())\n\ndef loadinput():\n\t(a, b, c, d) = map(int, input().split())\n\treturn (a, b, c, d)\n\ndef testval(str1, str2):\n\tif len(str1) < len(str2):\n\t\treturn True\n\tfor u in str2:\n\t\tif u not in str1:\n\t\t\treturn True\n(a, b, c, d) = loadinput()\nx1 = b * c - d * a\nx2 = a * d - c * b\nif a / b < c / d:\n\ta1 = int(x1 / math.gcd(x1, b * c))\n\ta2 = int(b * c / math.gcd(x1, b * c))\n\tprint(a1, '/', a2, sep='')\nelif c / d < a / b:\n\tprint(int(x2 / math.gcd(x2, a * d)), '/', int(a * d / math.gcd(x2, a * d)), sep='')\nelse:\n\tprint(0, '/', 1, sep='')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nif a / b == c / d:\n\tprint('0/1')\nelif a / b < c / d:\n\tr1 = (b * c - a * d) / (b * c)\n\tprint(Fraction(r1).limit_denominator())\nelif a / b > c / d:\n\tr = (a * d - b * c) / (a * d)\n\tprint(Fraction(r).limit_denominator())\n", "import sys as system\n\ndef gcd(x, y):\n\tif not y:\n\t\treturn x\n\treturn gcd(y, x % y)\n(a, b, c, d) = map(int, input().split())\nnod = gcd(b, d)\nnok = b * d // nod\nmn1 = nok // b\nmn2 = nok // d\na *= mn1\nb *= mn1\nc *= mn2\nd *= mn2\nif a == c:\n\tprint(str(int(0)) + '/' + str(int(1)))\n\tsystem.exit(0)\np = int(0)\nq = int(0)\nif a > c:\n\tp = a - c\n\tq = a\nelse:\n\tnod = gcd(a, c)\n\tnok = a * c // nod\n\tmn1 = nok // a\n\tmn2 = nok // c\n\ta *= mn1\n\tb *= mn1\n\tc *= mn2\n\td *= mn2\n\tp = b - d\n\tq = b\nnod = gcd(p, q)\np //= nod\nq //= nod\nprint(str(int(p)) + '/' + str(int(q)))\n", "from fractions import gcd\n(a, b, c, d) = map(int, input().split())\n(ax, bx, cx, dx) = (a, b, c, d)\n(a, b, c, d) = (a * d, b * d, c * b, d * b)\nmonitor = a * b\nfilm = c * d\nnegru = monitor - film\n(monitor, negru) = (monitor // gcd(monitor, negru), negru // gcd(monitor, negru))\nans1 = (negru, monitor)\n(a, b, c, d) = (bx, ax, dx, cx)\n(a, b, c, d) = (a * d, b * d, c * b, d * b)\nmonitor = a * b\nfilm = c * d\nnegru = monitor - film\n(monitor, negru) = (monitor // gcd(monitor, negru), negru // gcd(monitor, negru))\nans2 = (negru, monitor)\nif ans1[1] == 0 or ans1[0] / ans1[1] < 0:\n\tsol = ans2\nelif ans2[1] == 0 or ans2[0] / ans2[1] < 0:\n\tsol = ans1\nelif ans1[0] / ans1[1] < ans2[0] / ans2[1]:\n\tsol = ans1\nelse:\n\tsol = ans2\nprint('%i/%i' % sol)\n", "import fractions\n\ndef solve(a, b, c, d):\n\tif a * d == b * c:\n\t\treturn '0/1'\n\telif a / c > b / d:\n\t\treturn str(fractions.Fraction(a * d - c * b, a * d))\n\telse:\n\t\treturn str(fractions.Fraction(c * b - a * d, c * b))\n\ndef test():\n\tassert solve(1, 1, 3, 2) == '1/3'\n\tassert solve(4, 3, 2, 2) == '1/4'\n\tassert solve(1, 1, 1, 1) == '0/1'\n\tprint('test passes')\n(a, b, c, d) = tuple(map(int, input().split()))\nprint(solve(a, b, c, d))\n", "(a, b, c, d) = map(int, input().split())\n\ndef gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\nx = a * d\ny = b * c\ng = gcd(x, y)\nx //= g\ny //= g\nprint(str(abs(x - y)), end='')\nprint('/', end='')\nprint(max(x, y))\n", "import math\nimport sys\n(a, b, c, d) = list(map(int, input().split()))\nif a * d < c * b:\n\tt = math.gcd(b * c - a * d, b * c)\n\tprint((b * c - a * d) // t, '/', b * c // t, sep='')\nelse:\n\tt = math.gcd(a * d - b * c, a * d)\n\tprint((a * d - b * c) // t, '/', a * d // t, sep='')\n", "from fractions import Fraction\n(a, b, c, d) = map(int, input().split())\nk = min(Fraction(a, c), Fraction(b, d))\nA1 = a * b\nA2 = c * d\nA2 = A2 * k ** 2\nprint(f'{Fraction(A1 - A2, A1).numerator}/{Fraction(A1 - A2, A1).denominator}')\n", "(a, b, c, d) = map(int, input().split())\nx1 = a * d - c * b\nx2 = b * c - d * a\nif x1 > 0:\n\tma = x1\n\tf = a * d\nelse:\n\tma = x2\n\tf = b * c\nq = ma\nfor i in range(ma, 1, -1):\n\tif q % i == 0 and f % i == 0:\n\t\tf //= i\n\t\tq //= i\n\t\tbreak\nif q == 0:\n\tf = 1\nprint('%d/%d' % (q, f))\n", "from math import gcd\n(a, b, c, d) = map(int, input().split())\nxp = 0\nxq = 0\nif a / c < b / d:\n\txp = a\n\txq = c\nelse:\n\txp = b\n\txq = d\nnum = a * b * xq * xq - c * d * xp * xp\nden = a * b * xq * xq\ng = gcd(num, den)\nprint(str(num // g) + '/' + str(den // g))\n", "def gcd(a, b):\n\tc = a % b\n\treturn gcd(b, c) if c else b\n(a, b, c, d) = map(int, input().split())\nif a * d < b * c:\n\t(a, b, c, d) = (b, a, d, c)\np = a * d - b * c\nq = d * a\nt = gcd(p, q)\nprint(str(p // t) + '/' + str(q // t))\n", "from fractions import Fraction as f\n(a, b, c, d) = map(int, input().split())\nif f(a, b) < f(c / d):\n\tprint(f(b - a * f(d, c), b))\nelif f(a, b) > f(c / d):\n\tprint(f(a - c * f(b, d), a))\nelse:\n\tprint('0/1')\n", "from collections import Counter\n\ndef factorize(x):\n\tfs = Counter()\n\tp = 2\n\twhile p * p <= x:\n\t\twhile x % p == 0:\n\t\t\tx //= p\n\t\t\tfs[p] += 1\n\t\tp += 1\n\tif x > 1:\n\t\tfs[x] += 1\n\treturn fs\n\ndef reduce_fraction(n, d):\n\tif n == 0:\n\t\treturn (0, 1)\n\tn_fs = factorize(n)\n\td_fs = factorize(d)\n\t(rn, rd) = (1, 1)\n\tfor (f, ct) in (n_fs - d_fs).items():\n\t\trn *= f ** ct\n\tfor (f, ct) in (d_fs - n_fs).items():\n\t\trd *= f ** ct\n\treturn (rn, rd)\n\ndef solve(a, b, c, d):\n\tif d * a <= b * c:\n\t\tnum = b * c - a * d\n\t\tden = b * c\n\telse:\n\t\tnum = a * d - b * c\n\t\tden = a * d\n\treturn reduce_fraction(num, den)\n(a, b, c, d) = map(int, input().split())\nres = solve(a, b, c, d)\nprint(f'{res[0]}/{res[1]}')\n", "from fractions import gcd\n(a, b, c, d) = map(int, input().split())\nif a * d > c * b:\n\tans = a * d - c * b\n\tland = a * d\nelse:\n\tans = b * c - d * a\n\tland = b * c\nm = gcd(ans, land)\nbans = str(ans // m) + '/' + str(land // m)\nprint(bans)\n"]

difficulty: MEDIUM

source: codeforces

raw_problem:
B. Routine Problem

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as much space on the screen as possible and fits within it completely. Thus, he may have to zoom the movie in or out, but Manao will always change the frame proportionally in both dimensions.

Calculate the ratio of empty screen (the part of the screen not occupied by the movie) to the total screen size. Print the answer as an irreducible fraction p / q.

Input

A single line contains four space-separated integers a, b, c, d (1 ≤ a, b, c, d ≤ 1000).

Output

Print the answer to the problem as "p/q", where p is a non-negative integer, q is a positive integer and numbers p and q don't have a common divisor larger than 1.

Examples

Input

1 1 3 2

Output

1/3

Input

4 3 2 2

Output

1/4

Note

Sample 1. Manao's monitor has a square screen. The movie has 3:2 horizontal to vertical length ratio. Obviously, the movie occupies most of the screen if the width of the picture coincides with the width of the screen. In this case, only 2/3 of the monitor will project the movie in the horizontal dimension:

Sample 2. This time the monitor's width is 4/3 times larger than its height and the movie's frame is square. In this case, the picture must take up the whole monitor in the vertical dimension and only 3/4 in the horizontal dimension:

question:
Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as much space on the screen as possible and fits within it completely. Thus, he may have to zoom the movie in or out, but Manao will always change the frame proportionally in both dimensions.
Calculate the ratio of empty screen (the part of the screen not occupied by the movie) to the total screen size. Print the answer as an irreducible fraction p / q.

Input
A single line contains four space-separated integers a, b, c, d (1 ≤ a, b, c, d ≤ 1000).

Output
Print the answer to the problem as "p/q", where p is a non-negative integer, q is a positive integer and numbers p and q don't have a common divisor larger than 1.

Examples
Input
1 1 3 2

Output
1/3

Input
4 3 2 2

Output
1/4

Note
Sample 1. Manao's monitor has a square screen. The movie has 3:2 horizontal to vertical length ratio. Obviously, the movie occupies most of the screen if the width of the picture coincides with the width of the screen. In this case, only 2/3 of the monitor will project the movie in the horizontal dimension: ![image](1.png)
Sample 2. This time the monitor's width is 4/3 times larger than its height and the movie's frame is square. In this case, the picture must take up the whole monitor in the vertical dimension and only 3/4 in the horizontal dimension: ![image](2.png)

tags: ['Number theory', 'Mathematics', 'Greedy algorithms']

skill_types: ['Greedy algorithms']

image_tags: Others Others

data_split: test