STDOUT.sync = true A = 256 B = 128 Y = A.pow(B, 10**9+7) puts "#{A} #{B}" K = gets.to_i X = (100 .. 10**5).find { |x| x.gcd(Y) == K } puts X.pow(A, B)