Code Breakers

No attempts yetTime limit1sMemory limit128 MB

Problem

It is almost certain that the NSA intercepts and logs, and probably analyzes, much of the e-mail traffic in the world, and certainly in the US. One way organizations and individuals protect the privacy of their messages is encryption, and one of the cooler ideas in encryption is public key encryption. Roughly, it goes like this. You publish one key, so everyone can see it and use it to encrypt a message to you. Decrypting that message takes a different key, which only you know. The idea sounds nice, and the far bigger contribution was showing that it is actually mathematically possible, which is what the RSA algorithm did.

Here is how it works. You choose two prime numbers pp and qq (usually at random, though that does not matter for this problem). Your public key, which everyone can see, consists of the number n=p×qn = p \times q and a small number ee. Your private key, which only you should know, is a number d(p1)(q1)d \le (p-1)(q-1) such that (d×e)mod((p1)(q1))=1(d \times e) \bmod ((p-1)(q-1)) = 1. If you know pp and qq, finding such a dd is easy. If you do not, it seems difficult, and that is why only you, the owner of pp and qq, can decrypt the message.

Now, how to encrypt and decrypt a message. Say the message is a number mm (any string becomes a number by reading its bits as one). The encrypted version is c=memodnc = m^e \bmod n, which anyone can compute from nn and ee alone. To decrypt, the recipient computes cdmodnc^d \bmod n, which recovers the original message.

To break someone's key, it is enough to factor nn and recover pp and qq. This is believed, though not proved, to be hard as long as pp and qq are large enough (thousands of digits). If they are too small, brute force breaks RSA. That is what you will do here.

The R, S and A in RSA come from the surnames Rivest, Shamir and Adleman.

Input

The first line contains the number KK of data sets. Each of the next KK lines holds one data set as three integers nn, ee, cc separated by spaces, with 5n1095 \le n \le 10^9, 1e100001 \le e \le 10000 and 1c<n1 \le c < n. In other words, the attacker knows the public key and the encrypted message. In these inputs nn is always a product of exactly two primes, and ee is always given so that a dd satisfying the condition above exists.

Output

For each data set, print Data Set x: on a line by itself, where xx is its number. Then print the decrypted message mm of the ciphertext cc on a line by itself, followed by an empty line.