import math def solve(): # Step 1: Output A and B # Choose A and B strategically to get meaningful gcd results A = 12345 # Example value, can be adjusted B = 67890 # Example value, can be adjusted print(A, B, flush=True) # Output A and B, and flush output # Step 2: Receive K from the judge K = int(input()) # Judge provides K = gcd(X, Y) # Step 3: Use K to narrow down possible X values possible_X = [] for i in range(1, 10**5 // K + 1): # Enumerate multiples of K X = K * i if 100 <= X <= 10**5: # Ensure X is within the valid range possible_X.append(X) # Step 4: Compute X' for each possible X and guess for X in possible_X: # Calculate X' = X^A mod B X_prime = pow(X, A, B) # Use Python's built-in pow with three arguments print(X_prime, flush=True) # Output the guess for X' and flush # Step 5: Receive the judge's response (ret) ret = int(input()) # Judge responds with 1 if correct, 0 otherwise if ret == 1: return # Correct guess, exit the function solve()