F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

ShuanQ

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2073    Accepted Submission(s): 770


Problem Description
CX is a programmer of a mooc company. A few days ago, he took the blame for leakage of users' data. As a result, he has to develop an encryption algorithm, here is his genius idea.

First, the protocol specifies a prime modulus $M$, then the server generates a private key $P$, and sends the client a public key $Q$. Here $Q = P ^ {-1},P \times Q \equiv 1 \mod M$.

Encryption formula: $encrypted\_{data} = raw\_{data} \times P \mod M$

Decryption formula: $raw\_{data} = encrypted\_{data} \times Q \mod M$

It do make sense, however, as a master of number theory, you are going to decrypt it.You have intercepted information about $P, Q, encrypted\_{data}$, and $M$ keeps unknown. If you can decrypt it, output $raw\_{data}$, else, say "shuanQ" to CX.
 

Input
First line has one integer $T(T \leq 20)$, indicating there are $T$ test cases. In each case:

One line has three integers $P, Q, encrypted\_{data}$. ($1 < P, Q, encrypted\_{data} \leq 2 \times 10^6$)

It's guaranteed that $P, Q, encrypted\_{data} < M$.
 

Output
In each case, print an integer $raw\_{data}$, or a string "shuanQ".
 

Sample Input
2 5 5 5 6 6 6
 

Sample Output
shuanQ 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:30:59, Gzip enabled