# Constants MOD = 1000000007 MOD2 = 456 # Function to calculate power with modulo (modular exponentiation) def mod_pow(base, exp, mod): result = 1 while exp > 0: if exp % 2 == 1: result = (result * base) % mod base = (base * base) % mod exp //= 2 return result # Function to calculate gcd using Euclid's algorithm def gcd(a, b): while b != 0: a, b = b, a % b return a def main(): # Initial value of X is given as 100 X = 100 # Read inputs for A and B A, B = map(int, input().split()) # Step 1: Calculate Y = A^B % (10^9 + 7) Y = mod_pow(A, B, MOD) print(f"Judge is Y = {A}^{B} % (10^9 + 7) = {Y}") # Step 2: Calculate K = gcd(X, Y) K = gcd(X, Y) print(f"Judge is K = gcd(X, Y) = {K}") # Step 3: Calculate X' = X^K % 456 X_prime = mod_pow(X, K, MOD2) print(f"Judge is X' = X^{K} % 456 = {X_prime}") # Output final result print(f"Final X' = {X_prime}") if __name__ == "__main__": main()