# Arup Guha
# Printing out a substitution chart for affine keys.
# 8/31/2020

# Returns gcd(a,b).
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a%b)

def main():

    # Get a, b from user for affine.
    a = int(input("enter a\n"))
    b = int(input("enter b\n"))

    # Bad keys.
    if (gcd(a,26) != 1):
        print("Sorry not valid keys.")

    # Valid keys, let's print the chart.
    else:

        # Chart Header
        print("here is a substitution chart for your keys")
        print("Input\tOutput")

        # Go a to z.
        for i in range(26):

            # f(x) = ai + b mod 26
            out = (a*i+b)%26

            # Notice use of ord, chr, ord goes letter to ascii value
            # chr goes from ascii value to letter.
            print(chr(ord('A')+i), chr(ord('A')+out), sep='\t')

main()
