#!/bin/python3

import sys
import math

input_file = sys.argv[1]
diffout = sys.argv[3]

with open(input_file, "r") as f, open(diffout + "/judgemessage.txt", "w") as f2:
    a,b = [int(i) for i in f.readline().split()]
    if a == b or a == 0 or b == 0:#impossible
        try: 
            line1 = input()
        except EOFError:
            f2.write("Too few lines were provided.\n")
            sys.exit(43)
        try: 
            line = input()
            f2.write("Too many lines were provided.\n")
            sys.exit(43)
        except EOFError:
            pass
        if line1 != "impossible":
            f2.write("Wrong answer in impossible case.\n")
            sys.exit(43)
        else:
            sys.exit(42)
    else:
        try: 
            line1 = input()
            line2 = input()
        except EOFError:
            f2.write("Too few lines were provided.\n")
            sys.exit(43)
        try: 
            line = input()
            f2.write("Too many lines were provided.\n")
            sys.exit(43)
        except EOFError:
            pass
        try:
            p1,q1 = [int(i) for i in line1.split('/')]
            p2,q2 = [int(i) for i in line2.split('/')]
        except:
            f2.write("Output incorrectly formatted rationals.\n")
            sys.exit(43)
        if q1 <= 0 or q2 <= 0:
            f2.write("Incorrect denominators.\n")
            sys.exit(43)
        if math.gcd(p1,q1) > 1 or math.gcd(p2,q2) > 1:
            f2.write("Non-simplified rationals.\n")
            sys.exit(43)
        if q1 * a == p1 or q2 * a == p2:
            f2.write("Values are not different from a,b.\n")
            sys.exit(43)
        targval = a ** 3 + b ** 3
        q = (q1 * q2) ** 3
        p = (p1 * q2) ** 3 + (p2 * q1) ** 3
        if q * targval != p:
            f2.write(f"Result was {p} / {q}, expected {targval}.\n")
            sys.exit(43)
        sys.exit(42)
f2.write("Did not exit in time.\n")
sys.exit(43)