#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import math

def error():
    check = []
    test = 0
    if len(sys.argv) < 3:
        exit(84)
    for i in range(1, len(sys.argv)):
        if sys.argv[i][0] == '*' or sys.argv[i][-1] == '*':
            exit(84)
        for j in range(len(sys.argv[i])):
            if sys.argv[i][j] > '9' or sys.argv[i][j] < '0' and sys.argv[i][j] != '*' and sys.argv[i][j] != '-':
                exit(84)
            elif sys.argv[i][j] == '*' and sys.argv[i][j - 1] == '*':
                exit(84)
            elif sys.argv[i][j] == '-' and sys.argv[i][j + 1] == '*':
                exit(84)
    if sys.argv[2][0] == '0':
            exit(84)

def print_help():
    print("USAGE")
    print("\t   ./107transfer [num den]*\n")
    print("DESCRIPTION")
    print("\t   num\tpolynomial numerator defined by its coeficients")
    print("\t   den\tpolynomial denominator defined by its coeficients")

def help_me():
    if len(sys.argv) == 2:
        if sys.argv[1] == "-h":
            print_help()
        else:
            exit(84)

def calcul(tab):
    for k in range(len(tab)):
        for i in range(len(tab[k])):
            tab[k][i] = int(tab[k][i])
    for i in range(1001):
        c = 1
        for t in range(0, len(tab), 2):
            a = 0
            b = 0
            if tab[t] != tab[t + 1]:
                for j in range(len(tab[t])):
                    a = a + (tab[t][j] * ((i / 1000) ** j))
                for k in range(len(tab[t + 1])):
                    b = b + (tab[t + 1][k] * ((i / 1000) ** k))
                c = c * ((a / b))
        print("%.3f -> %.5f" % (i / 1000, c))

def main_function():
    tab = []
    for i in range(len(sys.argv[1:])):
        tab.append(sys.argv[i + 1].split("*"))
    calcul(tab)

def main():
    if len(sys.argv) == 2 and sys.argv[1] == "-h":
        print_help()
        exit(84)
    error()
    main_function()
main()
