The russian intelligence agency KGB make an encryption technique to send their passwords. Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C.
Now, Sherlock wants to decrypt the password encryption technique of KGB. Sherlock knows that every number has only 2 possible values which are following:
POSSIBLE VALUES OF "A": K, X
POSSIBLE VALUES OF "B": G, Y
POSSIBLE VALUES OF "C": B, Z
Help Sherlock to detect the encryption technique of the KGB and tell him the original password.
[See problem explanation for further clarifiaction]
INPUT:
The first line consist number of test cases T followed by T lines, each line consist of 3 space separated integers A, B, C.
OUTPUT
Print the correct message in format of C-C-C
Constraints:
1 ≤ T ≤ 50000
1 ≤ A, B, C ≤ 1000000000
SAMPLE INPUT
2
27 25 4
25 26 16
SAMPLE OUTPUT
K-G-B
X-Y-B
Explanation
For test case 1, the password sent is 27-25-4, then 27 can be either 'K' or 'X', similar case for 25 & 4. After applying the encryption 27 is converted into K, 25 is converted into G and 4 is converted into B.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
We are given a problem: "The russian intelligence agency KGB make an encryption technique to send their passwords. Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C.
Now, Sherlock wants to decrypt the password encryption technique of the KGB. Sherlock knows that every number has only 2 possible values which are following:
POSSIBLE VALUES OF "A": K, X
POSSIBLE VALUES OF "B": G, Y
POSSIBLE VALUES OF "C": B, Z
Help Sherlock to detect the encryption technique of the KGB and tell him the original password."
We have to output the correct message in format of C-C-C (maybe character-character-character). Sample input: 2 test cases: "27 25 4" -> output "K-G-B"; "25 26 16" -> output "X-Y-B". So for each test case we get three numbers A, B, C. For each number, there are two possible characters. We need to output exactly one of these possibilities, so the encryption technique maps numbers to letters. The question: "Help Sherlock to detect the encryption technique" meaning we need to deduce the rule that maps numbers to one of the two candidate letters.
Given the limited candidates: For A: K or X; for B: G or Y; for C: B or Z. So each number corresponds to a specific letter among the two. The rule must be consistent across all test cases. Since we have multiple test cases, the mapping from number to letter is not arbitrary: it's a deterministic function. We have to infer the function.
We are given sample mapping: 27 -> K, 25 -> G, 4 -> B. Also 25 -> X? Wait second test case: 25 -> X, 26 -> Y, 16 -> B. So same number 25 appears in both test cases: In first, A=25? Actually first test case: A=27, B=25, C=4. So B=25 mapped to G. In second test case: A=25, B=26, C=16. So A=25 mapped to X. So the mapping for number 25 is not fixed globally: For number 25, when it appears as B it maps to G; when it appears as A it maps to X. So the mapping depends on the position? Actually the problem says: "POSSIBLE VALUES OF 'A': K, X", etc. That suggests for the first number (A) the possible decrypted letters are K and X. For the second number (B) the possible letters are G and Y. For third (C) the possible letters are B and Z. So the mapping from a given number to a letter may differ based on which position it occupies. However, note: In the second test case, B=26 maps to Y, so 26 as B maps to Y. In the first test case, 27 as A maps to K. So the mapping might be something like: for A: if number is odd -> K, even -> X? Let's test: 27 odd -> K. 25 odd -> X (contradiction: 25 odd but mapped to X? Actually for A, 25 gave X, which would be even mapping? Let's check pattern: if odd->K, even->X, then 25 odd would be K, but sample says X. So not that.
Maybe the mapping is based on some property: For each position, we have two possible letters. The actual letter might be determined by some condition like whether the number is prime, or divisible by something, etc.
Let's list the sample:
Test case 1: A=27 -> K; B=25 -> G; C=4 -> B
Test case 2: A=25 -> X; B=26 -> Y; C=16 -> B
We need to guess rule.
We have constraints: A, B, C up to 1e9, so rule must be simple and based on arithmetic or parity, modulo, something.
Candidates:
For A: possible letters K and X. What distinguishes K from X? Could be: if number is divisible by something? 27 and 25: 27 gave K, 25 gave X. So opposite decisions. Perhaps based on whether number is a perfect square? 25 is square, 27 not square. But 4 is square but C gave B. For C: B or Z. 4 gave B, 16 gave B also. So both gave B. So for C, both 4 and 16 map to B. So maybe B is the default? But we need a rule that covers all.
Maybe each letter corresponds to a number range? Or maybe there is an underlying mapping from letters to numbers: K=??, X=?? etc. Could be based on alphabetical positions: K is 11, X is 24, G is 7, Y is 25, B is 2, Z is 26. Could be that the number is converted to a letter by taking its remainder mod something? For example, if number mod 26 gives a value that maps to letter. But candidate letters are only two per position, not all 26. So maybe each number is a sum of something? Or perhaps the encryption technique: original password is three characters, each character is encoded by a number based on something like the position in alphabet but then multiplied by something? Alternatively, perhaps the encryption technique is: For each character, they pick a number that is either the position of the character or that plus 26? Because we have two possibilities: K or X: K is 11, X is 24. Their sum 11+24=35? Not sure.
Let's see numeric values: K=11, X=24. For A=27, we got K (11). For A=25, we got X (24). 27-? 27-16=11? 25-1=24? Not obvious.
Maybe the rule is: For A, if the number is odd then it's K, else X? But 27 odd->K, 25 odd->X conflict. So not odd/even.
Maybe rule is: For each position, the number is either the alphabetical index of the letter, or that plus 23? Because 11->? 11+?=27? 11+16=27. For X=24, 24+?=25? 24+1=25. Not consistent shift.
Maybe it's: For each position, the number is either the letter's position, or the letter's position plus the position of the other letter? That seems messy.
Perhaps the encryption technique is: They pick a random number d (some key) and for each letter they output either its alphabetical index or its complement (27 - index) or something. For K (11), complement 27-11=16? That gives 16, not 27 or 25. Or maybe 26 - index? 26-11=15. 15 not 27. Not that.
Another idea: The encryption might be based on a simple cipher: They map letters to numbers via a linear function modulo something. For instance, they may have used a Caesar cipher with shift? But then number would represent the encrypted letter? Actually the problem says: "Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C." So they have a deterministic function f: character -> number (or possibly multiple numbers for each character). Sherlock knows that for each position, the number can be either of two specific letters. So the encryption technique maps each character to a number, but there are two possible numbers for each character? Wait: The problem says: "Sherlock knows that every number has only 2 possible values which are following: POSSIBLE VALUES OF 'A': K, X; POSSIBLE VALUES OF 'B': G, Y; POSSIBLE VALUES OF 'C': B, Z." That is ambiguous: It says "every number has only 2 possible values". Possibly they mean that for each number (like A) there are two possible characters it could represent. So the decryption mapping from numbers to characters is many-to-one? Actually they say: "Help Sherlock to detect the encryption technique of the KGB and tell him the original password." So given the numbers, we must determine which of the two possible characters each number corresponds to. So the encryption technique must be such that for each position, given the number, we can deduce whether it corresponds to one or the other character.
Thus we need to infer the rule that the KGB uses to encode a character into a number. They have two possible numbers for each character? Or the other way? The problem states: "Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C." So encryption transforms characters to numbers. So each character yields a number. But Sherlock knows that for each number A (the first encrypted number), the original character could be either K or X. So the encryption function is not injective: two different characters may map to the same number? Or maybe each character maps to a number, but the number is not unique: K and X both map to the same set of numbers? That seems contradictory: If encryption transforms characters to numbers, then given a number, we might have two possible original characters. That is exactly the situation: they gave possible values for A: K, X. So the number A could have come from either K or X. So the encryption mapping from characters to numbers is such that K and X map to numbers that are not necessarily the same? Actually if the number A is given, we know it could be either K or X, meaning that both K and X are possible original characters that could have produced that number under the encryption technique. So the encryption function E(character) = number. Then E(K) and E(X) could be two numbers? But then given a number, it could be from K if the number equals E(K) or from X if the number equals E(X). So the set of possible numbers for K is {E(K)} and for X is {E(X)}. But the problem says: "POSSIBLE VALUES OF 'A': K, X". It could be interpreted as: For the first number, the possible plaintext characters are K and X. So if we see the number, it might correspond to K or X. That means that E(K) and E(X) are both possible values that A can take? Actually careful: The plaintext is characters. The ciphertext is numbers. So encryption: f: character -> number. So if the plaintext character is K, then A = f(K). If it is X, then A = f(X). Therefore, when we see a specific A, we can deduce that if A equals f(K), then original is K; if A equals f(X), then original is X; if it equals something else, then not possible. The problem says that every number has only 2 possible values. That means that for any given A (in the input), it is guaranteed to be either f(K) or f(X). So A will always be one of the two numbers that correspond to K or X. So we need to determine which one it is.
Thus the encryption function maps K to some number(s) and X to some number(s). But they say "every number has only 2 possible values". Could also be interpreted that each number can be decrypted into either of two characters (the two given). So the encryption is ambiguous: the same number could represent K in some contexts or X in others? But that would be weird because then the decryption would not be unique. However, the problem asks to "tell him the original password", implying it is uniquely determined. So there must be an additional rule that determines which character it is based on the number itself.
Maybe the encryption technique is: For each character, they compute two numbers: one is the alphabetical index, and the other is something like the index times something, and then they pick one of them based on some condition (like parity). But then the number given is the result after picking. So we have to deduce which one they picked.
Given the sample, we have numbers: 27, 25, 4 for first. 25, 26, 16 for second. Let's map characters to their alphabetical positions: A=1, B=2, C=3, ..., K=11, X=24, G=7, Y=25, B=2, Z=26. So the positions: K=11, X=24, G=7, Y=25, B=2, Z=26.
Now consider the numbers: For first test: A=27 -> K(11). 27-11=16. B=25 -> G(7). 25-7=18. C=4 -> B(2). 4-2=2. The differences: 16,18,2. No obvious pattern.
Maybe the number is a multiple of something? 27 and 25 are not multiples of 11 or 24. Could it be that the number is the position plus 16 for first case? But 11+16=27, 7+18=25 (not 16). So not consistent.
Maybe the encryption is: For each character, they take its position and then either square it or something? 11^2=121, not 27. 3^3? 11? No.
Maybe the encryption technique uses a key: Perhaps they have a hidden number, like a base, and the number is the position plus the base. Then base might be 16 for first test? Since 11+16=27, 7+?=25 => 18, 2+?=4 =>2. So base varies per position? Or maybe base is determined by something like the sum of positions? Not.
Alternate view: Could be that the numbers are the product of the character position and something else? 11*? =27 -> not integer. 24*?=25 -> not.
Maybe the encryption technique is: They represent each character as a number in binary, then interpret as decimal? Unlikely.
Maybe the rule is based on whether the number is prime? 27 not prime, 25 not prime, 4 not prime, 25 not prime, 26 not prime, 16 not prime. So all composite? Not discriminating.
Maybe it's based on the remainder modulo some number. For A, we have two possible letters: K (11) and X (24). If we take the number modulo something, maybe it gives a value that matches the letter's position? For 27 mod 26 = 1, not 11. 27 mod 16 = 11? 27 mod 16 = 11, which is K's position. Interesting! 27 mod 16 = 11. For 25 mod ? = 24? 25 mod 1 = 0 not; 25 mod 2 = 1; mod 3 = 1; mod 4 = 1; mod 5 = 0; mod 6 = 1; mod 7 = 4; mod 8 = 1; mod 9 = 7; mod 10 = 5; mod 11 = 3; mod 12 = 1; mod 13 = 12; mod 14 = 11; mod 15 = 10; mod 16 = 9; mod 17 = 8; mod 18 = 7; mod 19 = 6; mod 20 = 5; mod 21 = 4; mod 22 = 3; mod 23 = 2; mod 24 = 1; mod 25 = 0; mod 26 = 25; mod 27 = 25; So 25 mod something equals 24? 25 mod 49? But 25 < 49, then 25 mod something where modulus > 25 gives 25 itself, not 24. 25 mod 1 = 0; 25 mod 2 = 1; etc. To get 24, we need 25 mod m = 24, i.e., m = 25-24=1, but mod 1 is 0. Actually condition: 25 ≡ 24 (mod m) => 25-24 = 1 ≡ 0 mod m => m divides 1, so m=1. But mod 1 is 0. So no. Maybe it's floor division? 25 // something = 24? That would be 25 // 2 =12; //1=25. So not.
Alternatively, maybe the number is the sum of the character's position and its complement (26 - position + 1)? For K (11), complement: 26-11+1=16? Actually alphabetical order: A=1, Z=26. Complement could be 27 - position? Because 1+26=27. So complement of 11 is 16. Then if we sum position and complement = 27. Indeed 11+16=27. That's A=27 for K. For X (24), complement is 27-24=3. 24+3=27? That would be 27, but A=25, not 27. So maybe they subtract? 24 + 1 = 25? Where does 1 come from? The complement of X is 3, not 1. Alternatively, maybe the complement is 26 - position? 26-24=2, sum = 26? Not 25.
Maybe it's the product? 11 * 2 = 22? Not 27.
Another thought: The encryption could be: They take the alphabetical index, and then they output either the square of that index, or the cube, etc. But 11^2=121, 11^3=1331. Not.
Perhaps they use the following: Represent the character in Morse code? No.
Maybe it's a simple substitution: Each letter corresponds to a fixed number, but there are two possibilities because they might have used two different encoding tables? But then the mapping would be one-to-one per test case but not across test cases. However, we need to output the correct one, so there must be some rule to choose.
We need to think of common simple encryption techniques used in puzzles. For example, the "KGB" might use a cipher where each letter is encoded as its position in the alphabet multiplied by some key and then taken modulo something. But then the output numbers are up to 1e9, so maybe it's a simple mapping: For each letter, they output either its position or the position of the letter that is 13 away (ROT13). ROT13: K (11) -> X (24) because 11+13=24. And X (24) -> K (11) because 24+13=37 mod 26 = 11? Actually 24+13=37 mod26=11. So K and X are ROT13 pairs. Similarly, G (7) and Y (25): 7+13=20? 20 is T, not Y. Actually 7+13=20 (T). So not ROT13. But maybe it's some other shift? G(7)+18=25 (Y). 7+18=25. B(2)+24=26 (Z). So the pairs are (K,X) differ by 13? 11 to 24 is +13. (G,Y): 7 to 25 is +18. (B,Z): 2 to 26 is +24. Not consistent.
Maybe the pairs are each other's opposite in alphabet? K is 11, from A=1 to Z=26, the opposite would be 26-11+1 = 16, which is P, not X. So no.
Perhaps the encryption technique is: They take the ASCII code? K ascii = 75, X = 88, difference 13. G=71, Y=89 difference 18. B=66, Z=90 difference 24. Not consistent.
Maybe the numbers A, B, C are the result of a mathematical operation: For each character, they take its alphabetical index and then either add the index of the next character, or multiply by something. But since the three numbers are independent? Possibly the encryption uses a key that varies per test case? But the problem seems to ask to deduce the technique, which must be fixed and then applied to each test case. So the technique is deterministic and known: given a character, you compute a number. However, from the input we only see the numbers; we need to reverse engineer which character produced each number. Since there are only two possibilities per position, we must be able to determine which one corresponds to the observed number.
Thus, we need to find two functions f_K and f_X such that for any test case, if A is the encrypted number, then either A = f_K()? Actually f depends on the character. So define function E(char) -> number. Then for char in {K, X} we have two possible numbers: E(K) and E(X). The given A is one of these two. So A is either E(K) or E(X). Which one it is determines the original character. So we need to compute both E(K) and E(X) from something, and see which matches A. But we don't know E. So we must deduce E from the sample. And likely E is simple.
Given that the numbers are up to 1e9, maybe E(char) is something like: char's position raised to a power, or multiplied by a constant. Let's try to see if there is a pattern: For position 1 (A) we have two possible numbers: 27 (when char K) and 25 (when char X). For char K (pos 11), the output is 27. For char X (pos 24), the output is 25. So the output is not monotonic with position; a higher position (24) gives a lower number (25) than the lower position (11) gives 27. So perhaps E(char) = some function that yields a number that is not simply the position.
Maybe E(char) = (some constant) - position? If constant = 38, then 38-11=27, 38-24=14, not 25. Constant = 36: 36-11=25, but 36-24=12, no. For char X we need 25, so constant - 24 = 25 => constant = 49. Then for K: 49-11=38, not 27. So not subtraction.
Maybe E(char) = position * something + offset. Solve for K: 11a + b = 27; for X: 24a + b = 25. Subtract: 13a = -2 => a = -2/13, not integer. So not linear.
Maybe E(char) = something like position squared mod something? 11^2=121, 24^2=576. No.
Maybe E(char) = position + (position of its pair)? For K and X are paired; maybe they encode both possibilities: The number is the sum of the two possible letters? For A, K and X sum positions 11+24=35. Not 27 or 25. Or maybe the number is the product? 11*24=264.
Alternatively, maybe the encryption technique is: They take the character, convert to its position, then apply a Caesar cipher with a shift that is the position of the character itself? That would produce a number. For char K (pos=11), if we shift it by its own position, 11+11=22, not 27. If shift by something else.
Maybe it's a base conversion: Represent the character's ASCII in a different base? Not.
Another angle: Perhaps the encryption technique is based on the fact that each letter corresponds to a number in a set like {2,4,8,16,32,...}? But letters given: K, X, G, Y, B, Z. Could be that the numbers are powers of two? 4 is 2^2 (B), 16 is 2^4 (B or Z? both 16? Actually C=16 gave B, not Z). 27,25,26 are not powers of two.
Maybe it's about representing the letter as a sum of two powers of two? K=11 = 8+2+1? Not.
Maybe the encryption technique is: They take the position, write it in binary, reverse the bits, interpret as decimal? That would be odd.
Given that the problem appears on some coding platform (maybe CodeChef or something), it's likely a simple trick: For each number, decide whether it corresponds to the first or second possible letter based on something like parity or being a multiple of a certain number. For example, for A, if the number is odd, output K, else X? 27 odd -> K; 25 odd -> X? But 25 is odd, gives X, so parity fails. If number mod 3? 27 mod 3 = 0 -> K; 25 mod 3 = 1 -> X? But we need a rule that works for both and also for B and C. Let's test: For B: numbers 25 (first test) gave G; 26 (second) gave Y. 25 odd -> G? 26 even -> Y? Could be: for B, if odd -> G, even -> Y. 25 odd -> G, 26 even -> Y. That works for these two. For C: 4 gave B, 16 gave B. Both even, so if rule for C: if even -> B, odd -> Z? Both even give B; we need to check if any odd would give Z. Possibly. For A: 27 odd gave K; 25 odd gave X (contradiction if odd->K). So parity fails for A.
Maybe for A, the rule is based on modulo 4? 27 mod4=3 -> K; 25 mod4=1 -> X. Not consistent (both odd but different mod4). Could be: if number mod 10? 27 mod10=7 -> K; 25 mod10=5 -> X. Not.
Maybe the rule is: For each position, the character is the one whose alphabetical index has the same parity as the number? For A: K=11 odd, X=24 even. Number 27 odd -> matches K (odd). Number 25 odd -> matches X? X is even, so mismatch. So not.
Maybe the rule is: For each position, the character is the one whose position is a divisor of the number? For A: 27 divisible by? 27 divisible by 3,9,27. 11 not a divisor; 24 not a divisor. So no.
Maybe the rule is: For each position, the character is the one whose position is closer to the number? 27: distance to 11 =16, to 24=3 -> choose closer 24? But they chose 11. So not.
Maybe the encryption technique uses a key that is the same for all three numbers in a given test case. For instance, maybe they have a secret number N, and for each character they output either position+N or position*N? Then given three numbers we could solve for N and the positions. For test case1: Suppose we have positions p1,p2,p3 (unknown from {11,24}, {7,25}, {2,26}) and a transformation f(p,N) = something. We have numbers: a=27,b=25,c=4. Need to find N such that for some combination of p choices, the equations hold. If f(p,N)=p+N, then p1+N=27, p2+N=25, p3+N=4. Then N = 27-p1 = 25-p2 = 4-p3. If we try p1=11 => N=16; then p2=7 => N=18 (mismatch). p1=11 => N=16; p2=25 => N=0 (mismatch). p1=24 => N=3; p2=7 => N=18; no. So not addition.
If f(p,N)=pN: then p1N=27, p2N=25, p3N=4. N would be rational; not integer.
If f(p,N)=N/p? No.
If f(p,N)=N - p: then N - p1=27 => N=27+p1; N - p2=25 => N=25+p2; equating: 27+p1=25+p2 => p2 = p1+2. Possible p1=11 => p2=13 (not 7 or 25). p1=24 => p2=26 (not 7 or 25). So no.
If f(p,N)=N / something? Unlikely.
Maybe transformation involves the product of positions? For instance, A = p1 * p2? But then A would depend on B's char, which is not given independently.
But the problem statement says: "Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C." So each character independently becomes a number. So the encryption function is per character, not mixing.
Thus, we need to find a function E that maps each character (from a set of two per position) to a number. The function might be the same for all positions? But the sets of characters differ per position. However, maybe the function is something like: E(character) = (position_in_alphabet)^2 + something. Let's compute positions: K=11, X=24, G=7, Y=25, B=2, Z=26.
We have outputs: For K -> 27, X -> 25, G -> 25? Wait, careful: In test case1, B=25 corresponds to G. So G (7) -> 25. In test case2, A=25 corresponds to X (24). So X (24) -> 25. So two different characters map to the same number 25? That would be ambiguous: 25 could be from G or X. But the problem says each number has only 2 possible values. For A, the possible values are K,X; for B, the possible values are G,Y; for C, B,Z. So if we see number 25 as A, it could be K or X; as B, it could be G or Y. So the same number 25 can appear in different positions with different interpretations. So E(K) might be 27, E(X) might be 25, E(G)=25, E(Y)=? In test case2, B=26 -> Y, so E(Y)=26. Also E(B)=? In test case1, C=4 -> B, so E(B)=4. In test case2, C=16 -> B, so E(B)=16? That can't be: the same character B cannot map to two different numbers unless there is additional context. Wait: In first test case, C=4 maps to B. In second, C=16 maps to B. So the number 4 and 16 both map to B. So E(B) is not a single number. So the encryption function is not a function from characters to numbers; it's more like a function from characters to numbers that can vary depending on something else. That suggests the encryption technique might involve a key that changes per message, but the key is not given. But the problem expects us to output the original password given only the numbers. So there must be a deterministic way to deduce the characters from the numbers alone, without additional key. That implies that the mapping from numbers to characters is one-to-one per position given the numbers? But if the same number can correspond to different characters in different positions, that's okay because position is fixed. But for a given position, the mapping from number to character might be many-to-one? For C, both 4 and 16 map to B. So for the third position, the number could be either 4 or 16, and both would decode to B. So the character B can be represented by multiple numbers. Similarly, maybe Z can be represented by multiple numbers. So the encryption is such that each character maps to a set of numbers (maybe infinite) and the two characters for a position have disjoint sets? Actually they must be disjoint because otherwise ambiguity. So for C, the set for B and the set for Z are disjoint. 4 and 16 are in B's set; maybe Z's set includes other numbers like 2? Not sure. For B, we have G and Y: 25 maps to G, 26 maps to Y. So G's set includes 25? And maybe other numbers? Y's set includes 26? Possibly also others. For A, K's set includes 27, and X's set includes 25. So indeed, the encryption technique might be: For each character, they take its position p, and output p^2? 11^2=121, not 27. p^2 mod something? p^2 mod 41? 11^2=121 mod 41 = 39, not 27. Maybe they output p + k, where k is something like the square of something? But k varies per test case.
Maybe the encryption technique is: They take the character, and output either p * 2 or p * something? Let's think: For B in test case1, p=7, output 25. That's roughly 73.57. For Y in test case2, p=25, output 26 ~ 251.04. Not constant factor.
Maybe the encryption is: Output = p + d, where d is a secret number that depends on the test case but is the same for all three positions in that test case? Let's test: For test case1, if we assume d is constant across the three numbers, then we have:
For A: p1 + d = 27 -> p1 = 27 - d
For B: p2 + d = 25 -> p2 = 25 - d
For C: p3 + d = 4 -> p3 = 4 - d
p1 must be either 11 or 24. p2 either 7 or 25. p3 either 2 or 26.
Solve for d from each equation:
From p1: d = 27 - p1
From p2: d = 25 - p2
From p3: d = 4 - p3
We need a d that makes all three p's valid choices. Let's try combinations:
If p1=11 => d=16. Then p2 = 25 - 16 = 9, not 7 or 25. So no.
p1=24 => d=3. Then p2 = 25 - 3 = 22, not 7 or 25.
So no constant d.
If p1=11 => d=16; p3 = 4 - 16 = -12 invalid. So no.
Thus not additive constant.
Maybe multiplicative constant: Output = p * d. Then:
27 = p1 * d, 25 = p2 * d, 4 = p3 * d.
d must be rational. For p1=11 => d=27/11 ~2.4545; then p2=25/d ≈ 25 * 11/27 ≈ 10.185, not 7 or 25. p1=24 => d=27/24=1.125; p2=25/1.125≈22.22, not 7 or 25. So no.
Maybe output = d / p? unlikely.
Perhaps the encryption involves exponentiation: p ^ d? No.
Given the wide range up to 1e9, maybe the encryption technique is: Represent the character as a bit in a number? Or maybe they use a base-2 representation: For each character, they output the number where the bit corresponding to its position is set. For example, if they output 2^(p-1). Then K (p=11) would be 2^10=1024, not 27. X=2^23 huge. So no.
Maybe they output p + 16 for some, p+1 for others? Not consistent.
Maybe the encryption technique is: For each character, they output the number of its position in the alphabet but in a different base? For instance, interpret the position as a number in base something and convert to decimal? 11 in base 3 is 4? Not.
Let's step back. The problem statement: "The russian intelligence agency KGB make an encryption technique to send their passwords. Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C.
Now, Sherlock wants to decrypt the password encryption technique of KGB. Sherlock knows that every number has only 2 possible values which are following:
POSSIBLE VALUES OF "A": K, X
POSSIBLE VALUES OF "B": G, Y
POSSIBLE VALUES OF "C": B, Z
Help Sherlock to detect the encryption technique of the KGB and tell him the original password.
[See problem explanation for further clarifiaction]"
Maybe there is a missing explanation: It could be a known puzzle about "KGB encryption" that involves the number of letters in the words for numbers? Or maybe it's about the positions on a phone keypad? Or about the shape of letters? Could be that the numbers represent the number of straight lines in the letter? For K, maybe 3 lines? X has 2? But 27 is not that. Or maybe they use the "digital root" or something.
Let's think of possible simple functions: For a given letter, the number could be the sum of the ASCII codes of the letter and its mirror? Not.
Given that the sample outputs are exactly one of the two letters per position, maybe the rule is: For each number, if it is a perfect square, choose one letter; if not, choose the other. Let's check: For test case1: A=27 (not perfect square) -> K; B=25 (perfect square) -> G; C=4 (perfect square) -> B. For test case2: A=25 (perfect square) -> X; B=26 (not perfect square) -> Y; C=16 (perfect square) -> B. So:
For A: 27 (non-square) -> K; 25 (square) -> X. So if square, X; else K. That matches: square -> X (second option), non-square -> K (first option). Check: In sample, 25 square gave X, 27 non-square gave K. So plausible.
For B: 25 square -> G; 26 non-square -> Y. So if square -> G (first option), non-square -> Y (second option). That matches sample.
For C: 4 square -> B; 16 square -> B. Both squares gave B. What about non-square? If we had a non-square, maybe it would be Z. So rule: for C, if square -> B, else Z. That matches: both squares gave B.
Thus the rule could be: For each position, depending on whether the number is a perfect square or not, pick one of the two letters. For A: square => X, non-square => K. For B: square => G, non-square => Y. For C: square => B, non-square => Z.
Let's test with other potential numbers? Could there be any contradictions? It's simple and fits the sample. Also the numbers can be up to 1e9, and checking perfect square is easy.
But is that the intended encryption technique? Possibly. However, we must verify if there is any other property. The problem says "Help Sherlock to detect the encryption technique". That would be a plausible detection: they are using the property of being a perfect square to decide which letter to use.
But why would the KGB use that? Maybe they encode each character as either its position or its complement based on whether the resulting number is a square? But we don't need backstory.
We should consider if there might be alternative rules like prime, even, etc. But square fits perfectly.
Double-check: In test case1, A=27 not square -> K (first of K,X). B=25 square -> G (first of G,Y). C=4 square -> B (first of B,Z). In test case2, A=25 square -> X (second of K,X). B=26 not square -> Y (second of G,Y). C=16 square -> B (first of B,Z). So for A, square picks the second; for B, square picks the first; for C, square picks the first. So the mapping of square/non-square to first/second is not consistent across positions; it's specific per position. That's okay because the possible letters are listed; we need to know which one corresponds to square condition.
Thus the decryption technique: For each test case, given A, B, C, output:
For A: if A is a perfect square, output "X"; else output "K".
For B: if B is a perfect square, output "G"; else output "Y".
For C: if C is a perfect square, output "B"; else output "Z".
Let's test with sample: 27 -> not square -> K; 25 -> square -> G; 4 -> square -> B => "K-G-B". Good. 25 -> square -> X; 26 -> not square -> Y; 16 -> square -> B => "X-Y-B". Good.
Thus the solution seems to be checking perfect squares.
But is there any nuance? Could the numbers be up to 1e9, so we can compute integer square root via sqrt in double and check, or use integer sqrt.
We must also consider that 0? But constraints say 1 ≤ A,B,C ≤ 1e9, so positive.
Thus answer: For each test case, output three letters separated by hyphens.
But we must be careful: The problem might have additional twist: maybe the encryption technique uses "KGB" as a mnemonic: K, G, B are the "first" letters? Actually K, G, B are the letters that correspond to non-square? Wait K, G, B are the ones that appear in the first test case: all first letters. But in the second, we have X, Y, B. B is first letter for C, but for C both test cases gave B. So it's consistent: for C, square always gives B.
What about the fact that for C, 16 is square -> B, 4 is square -> B. So indeed B is for square, Z for non-square. So the rule is:
A: K if not perfect square, X if perfect square.
B: G if perfect square, Y if not.
C: B if perfect square, Z if not.
But wait: Check B: 25 square -> G, 26 not square -> Y. So yes.
But could it be reversed? Maybe the rule is: For A, if perfect square then second (X), else first (K). For B, if perfect square then first (G), else second (Y). For C, if perfect square then first (B), else second (Z). So it's not uniform. That's plausible given the problem statement just lists two possible values per position but doesn't indicate order. But the order listed might be the order: first is maybe the "default"? But they explicitly list "K, X" for A. So we can deduce from sample that for A, square yields X (the second), non-square yields K (first). For B, square yields G (first), non-square yields Y (second). For C, square yields B (first), non-square yields Z (second). So the mapping of condition to position is not the same. That is acceptable.
But we should double-check if there is any alternative rule like "the number is a multiple of something" or "the number modulo something equals something". For A, 27 mod? 27 mod something might equal something related to letter positions. But perfect square is the simplest.
Maybe there is another property: For A, both 27 and 25 are odd, so parity not. But square condition works.
Consider other possible numbers: If we had A=36 (square) -> X. B=36 (square) -> G? Actually B square -> G, yes. C=36 (square) -> B. That would be plausible.
But could there be any number that is a square but also could be interpreted differently? Since mapping is fixed, it's fine.
Thus the solution is to check if each number is a perfect square.
We must implement efficiently for up to 50000 test cases. For each number up to 1e9, we can compute integer sqrt using int(sqrt(n)) or using binary search. Use sqrt in double and adjust: s = (int)round(sqrt(n)); if s*s == n -> perfect square. But be careful about floating point precision for large numbers (1e9 is safe for double? sqrt(1e9)=31622.7766, double has 53 bits precision ~ 15-16 decimal digits, so exact integer sqrt for numbers up to 1e9 is fine. But to be safe, use integer sqrt via (int)floor(sqrt(n)) and check.
Alternatively, we can use a binary search.
Thus algorithm:
Read T.
For each test case:
read a,b,c.
char1 = 'X' if is_perfect_square(a) else 'K'
char2 = 'G' if is_perfect_square(b) else 'Y'
char3 = 'B' if is_perfect_square(c) else 'Z'
print f"{char1}-{char2}-{char3}"
But wait: The sample output uses uppercase letters and hyphens. So format exactly like that.
Now, is there any hidden catch? The problem says "Help Sherlock to detect the encryption technique of the KGB and tell him the original password." Possibly there is more to it: maybe the encryption technique is that each number is the sum of the squares of the digits of the letter? But no.
Another angle: The letters K, X, G, Y, B, Z are not arbitrary; they might be the initials of "KGB" and "XYZ"? KGB is the agency, and XYZ perhaps? Actually K, G, B are the letters of KGB. And X, Y, Z are the last three letters. So indeed, the two possibilities for each position are: the first letter of KGB (K) and the last letter of the alphabet (X) for first position? That seems like a pattern: The first character of the password can be either K (first letter of KGB) or X (last letter of the alphabet?). The second can be G (second letter of KGB) or Y (second last letter of alphabet). The third can be B (third letter of KGB) or Z (third last letter of alphabet). Yes! That's a perfect pattern: K,G,B are the three letters of "KGB". X,Y,Z are the last three letters of the alphabet. So the encryption technique likely uses the property of perfect squares to choose between the "KGB" letters and the "XYZ" letters. That is very plausible: If the number is a perfect square, perhaps they use the XYZ set? But sample shows: For A, perfect square -> X (XYZ), non-square -> K (KGB). For B, perfect square -> G (KGB), non-square -> Y (XYZ). For C, perfect square -> B (KGB), non-square -> Z (XYZ). So the mapping per position is not uniformly "square -> XYZ". For B, square gave G (KGB). So maybe the rule is: For each position, if the number is a perfect square, output the letter from the word "KGB"? Let's check: For A, square -> X (not KGB). So no. Alternatively, maybe the rule is: For the first position, if square, output the letter from the end (X), else from start (K). For second, if square, output the letter from start (G), else from end (Y). For third, if square, output the letter from start (B), else from end (Z). That is a pattern: first: square -> end, second: square -> start, third: square -> start. Not consistent.
Maybe the rule is: For each position i (1-indexed), if the number is a perfect square, output the letter from "KGB" if i is odd? A is position 1 (odd) -> square? but square gave X, not K. So no.
Perhaps the rule is: For each position, output the letter from "KGB" if the number is a perfect square and the position is not 1? Hmm.
Let's not overcomplicate; the pattern of KGB and XYZ is clearly intentional. The encryption technique likely uses the property of being a perfect square to toggle between the two sets. But the toggling pattern might be: For each digit, if the number is a perfect square, then the letter is the one from the set (K,G,B) if the number itself is also something? Could be that the encryption is: For each character, they take the letter's position in alphabet, and if the letter is from KGB, they output its square; if from XYZ, they output its square plus something? But that's the reverse direction.
Given the sample, the rule derived earlier is correct. We should check if there is any other test case that would break it. Could we think of a scenario where a number is both a perfect square and non-perfect square? No.
Thus I think the intended solution is to check perfect square.
But I recall a similar problem on CodeChef or somewhere: "KGB Encryption" maybe. I've seen a problem about "KGB" and "XYZ" and perfect squares. Quick search memory: There's a problem named "KGB" on CodeChef? Actually I recall a problem "KGB" from some contest: The encryption technique: They replace each character with a number. For each character, if it is a consonant, they use its position squared; if vowel, they use something else? Not sure.
Alternatively, maybe the rule is: For each character, if the character is from KGB, they output its position in the alphabet squared? Let's test: K=11, squared=121 (not 27). X=24, squared=576 (not 25). So no.
Maybe they output the position multiplied by the position's reverse? Not.
Another possibility: The encryption technique could be based on the sum of digits? 27 sum digits 9, 25 sum 7, 4 sum 4. Not.
Maybe it's based on the number of factors? 27 has 4 factors, 25 has 3, 4 has 3. Not.
The perfect square test is straightforward and fits both cases.
But let's verify for C: 4 and 16 are both perfect squares, and they output B. That's consistent with square->B. If they had a non-square like 5, they would output Z. That makes sense.
Thus I'll adopt the perfect square rule.
Implementation details:
Function is_square(n):
root = int(math.isqrt(n)) # Python 3.8+ has math.isqrt for integer sqrt
return root * root == n
For older versions, use int(math.sqrt(n)) and check.
Edge cases: n=1 (square) -> for A: X; B: G; C: B.
Now, the problem statement: "Print the correct message in format of C-C-C" but sample shows "K-G-B" etc. So it's letter hyphen letter hyphen letter.
Thus output.
We should consider if there is any other hidden condition like the numbers could be extremely large and checking perfect squares might be time-consuming for 50000 cases? It's fine; sqrt is O(1) with floating point or integer sqrt.
Thus solution is simple.
But before finalizing, let's think if any other property could also fit the sample. For example, maybe the rule is: For A, if the number is divisible by 3, then K else X? 27 divisible by 3 -> K; 25 not divisible by 3 -> X. That works for A. For B: if divisible by 5? 25 divisible by5 -> G; 26 not divisible by5 -> Y. Works for B. For C: if divisible by 4? 4 divisible by4 -> B; 16 divisible by4 -> B. So that also fits! Let's check: For C, if divisible by 4 then B, else Z. That fits both samples. So alternative rule: A: divisible by 3? B: divisible by 5? C: divisible by 4? Could be. But is that plausible? Why would they choose divisors 3,5,4? Maybe corresponding to position: first uses 3, second uses 5, third uses 4. Not obvious. But the perfect square rule seems more elegant because it ties into the KGB/XYZ pattern. However, the divisibility rule also fits sample, but we need to see if it's unique. Let's test another random number: Suppose A=9 (divisible by 3) -> K? According to perfect square, 9 is square -> X. So the two rules give different predictions. Which one would be the intended? We need to deduce from the context or maybe from the phrase "KGB encryption technique". Also the fact that the letters are K,G,B and X,Y,Z suggests a symmetry: maybe they use squares because squares are "square numbers" and KGB could be an acronym for something like "Koren' Govno B?" No.
Maybe there is hidden explanation: "KGB" might stand for "K is for K, G is for G, B is for B". But the two sets are KGB and XYZ. The numbers could be the positions squared? Let's compute positions: K=11, 11^2=121; G=7, 49; B=2,4. That's interesting: B's square is 4, which matches the number 4 in first test case! For B in first test case, C=4 maps to B. So for B (character B), its square is 4. For C in second test case, 16 maps to B; 16 is 4^2, but B's position is 2, not 4. Wait, B's square is 4, but 16 is 4^2, which is the square of 4 (which is D). Not directly B. However, maybe for C, the number could be the square of the position of the letter from the XYZ set? Z=26, square=676 not 16. So not.
But note: 4 is square of 2 (B). So in first test case, C=4 is exactly the square of B's position (2). So perhaps for C, if the original character is B, they output its position squared (2^2=4). If the original is Z, they output something else? In second test case, C=16, which is 4^2, but original is B, not 4. So not consistent.
But perhaps the encryption technique is: For each character, they output either the position (if some condition) or the square of the position (if other condition). For B, position=2, square=4. In first test case, B output 4 (square). In second test case, B output 16, which is 4^2? But 4 is not 2. Could be 2^4? 2^4=16. So maybe they output 2^4? That is exponentiation with exponent 4? Not systematic.
Alternatively, maybe they output the position raised to the power of the position? 2^2=4, 2^?=16 would be 2^4=16, but why exponent 4? Could be the position of the other letter? Not.
Given the perfect square rule is simple and fits both test cases and also ties to the letters KGB/XYZ (since perfect squares are "square" and maybe "KGB" stands for something like "Kvadrat"? Actually in Russian, "квадрат" means square. But KGB is not an abbreviation for square. However, KGB might be a red herring.
Nevertheless, the perfect square rule is very plausible and often appears in puzzles.
But we also found the divisibility rule (by 3,5,4) that fits sample. Could there be any other? For A: if number % 2 == 1? but 27 and 25 both odd, so can't differentiate. So parity not.
Maybe for A, if number % 4 == 3 then K else X? 27%4=3 -> K; 25%4=1 -> X. That works. For B: if number % 5 == 0 then G else Y? 25%5=0 -> G; 26%5=1 -> Y. For C: if number % 4 == 0 then B else Z? 4%4=0 -> B; 16%4=0 -> B. That also works. So rule: A: if (A % 4 == 3) then K else X? Actually 27%4=3 -> K; 25%4=1 -> X. So we could define: if A mod 4 == 3 -> K, else X. But what about other numbers like 7? 7%4=3 -> K, but is 7 a valid A? Could be. Is that the intended? Possibly not because it's arbitrary.
Another candidate: A: if A is odd -> K? But 25 odd -> X, so no.
Another: A: if A % 3 == 0 -> K else X. That fits: 27%3=0 -> K, 25%3=1 -> X. So mod 3 works. For B: if B % 5 == 0 -> G else Y. For C: if C % 4 == 0 -> B else Z. So the moduli are 3,5,4. Where do these numbers come from? 3,5,4 could be the number of letters in? Or maybe the positions of the letters? K is 11, G is 7, B is 2; sum? Not.
What about perfect square: 27 not square, 25 square; 4 square, 16 square. So condition: square vs non-square.
Both sets of conditions fit sample. We need to determine which one is correct based on typical puzzle design. The problem likely expects to "detect the encryption technique". That means we need to infer from the given information what the mapping is. Usually, they would design a rule that is consistent and perhaps based on a property like perfect squares, which is more interesting than arbitrary moduli. Also, the fact that the letters are K,G,B and X,Y,Z, and that 4 and 16 are both squares, and that 25 is a square, 27 is not, suggests the perfect square rule. Moreover, the perfect square rule applies uniformly to all positions: just check if the number is a perfect square. The mapping from that boolean to the letter differs per position, but that's given by the two options. So the rule could be: For each number, if it is a perfect square, choose the "second" option for A, the "first" for B, the "first" for C. But that seems arbitrary. However, the puzzle might be solved by noticing that the numbers that correspond to K,G,B are either squares or not? Let's list:
For A: K appears with 27 (non-square), X with 25 (square).
For B: G appears with 25 (square), Y with 26 (non-square).
For C: B appears with 4 (square) and 16 (square). So for C, B always with square, Z would be with non-square (though not in sample). So it's consistent: K is non-square, X is square; G is square, Y is non-square; B is square, Z is non-square.
Thus the rule can be succinctly: For each position, the character is the one that matches the squareness: For A, square -> X, non-square -> K; for B, square -> G, non-square -> Y; for C, square -> B, non-square -> Z.
That is a clean rule: it's simply: square yields the letter from the set {X, G, B}? Actually for A it's X, for B it's G, for C it's B. So square yields the set (X, G, B) which is not a known set; but notice that {X,G,B} are not all from XYZ or KGB; it's mixed: X from XYZ, G from KGB, B from KGB. So not uniform.
Alternatively, if we use the mod rule: A mod 3 == 0 -> K, else X; B mod 5 == 0 -> G, else Y; C mod 4 == 0 -> B, else Z. That's also a rule, but why mod 3,5,4? Could be derived from the positions: K=11, X=24; maybe the modulus is the sum of their positions? 11+24=35, not 3. Or maybe the modulus is the difference? 24-11=13, not 3. Not obvious.
Thus perfect square seems more natural because squares are a common property. Also note that 4 and 16 are both powers of 2 but also squares. 25 is square. So all numbers that are squares in the sample correspond to one of the letters (X, G, B) while non-squares correspond to the other letters (K, Y, ?). So it's consistent: squares always map to the same side per position.
Check: For A: square (25) -> X; non-square (27) -> K. For B: square (25) -> G; non-square (26) -> Y. For C: squares (4,16) -> B. So indeed squares map to {X,G,B} and non-squares map to {K,Y,Z}. That's interesting: {X,G,B} is not a natural set, but {K,Y,Z} also not. However, note that the letters K, Y, Z are the ones that appear in the second test case for A and B? Actually second test case gave X,Y,B. So non-square gave Y? But Y is from B in second test? Wait second test: B=26 non-square -> Y. So Y is non-square. So non-squares are {K, Y, Z}. So the sets are disjoint: squares: X,G,B; non-squares: K,Y,Z. That is a clean partition: one set contains X,G,B (mixed), the other contains K,Y,Z (mixed). But maybe there is a hidden pattern: Look at alphabetical positions: K=11, Y=25, Z=26 (non-squares). X=24, G=7, B=2 (squares). Are these positions squares? 2 no, 7 no, 24 no. So not.
Another observation: The sum of positions of the squares set: 24+7+2=33. Non-squares: 11+25+26=62. Not particularly.
Maybe the rule is simply: For each position, if the number is a perfect square, output the letter that is not from the KGB? But for B, square gave G which is from KGB, so not.
Given the ambiguity, we need to be certain. Let's search memory: I think I've seen a problem "KGB Encryption" on HackerEarth or CodeChef. Let me try to recall. Possibly it's from a contest called "KGB" or something. The description: "The russian intelligence agency KGB make an encryption technique to send their passwords. Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C." I think I recall a problem where the answer was based on perfect squares. I've seen similar: "KGB" and "XYZ" and the numbers: they correspond to the squares of the positions? Actually there is a known problem: "KGB" by Cedric? Not sure.
Let's think logically: The encryption technique must be something that can be applied to any character from the two sets. If we assume the rule is based on perfect squares, then to encrypt a password, they would first decide which character (from the two possibilities) they want, and then produce a number that is either a square or not accordingly, and also perhaps some other constraints. But the numbers given are arbitrary within 1e9, not necessarily predetermined to be squares or non-squares for the character. For example, if the password character is K, they must output a non-square number. But there are infinitely many non-squares. How do they choose which non-square? It could be any non-square. In the sample, for K they output 27, a non-square. For X they output 25, a square. So indeed, for a given character, the number must be either a square (if the character is from the set that requires square) or non-square (if the character requires non-square). But the actual value could be any square or non-square. So the encryption technique might be: For each character, they choose a random number that is either a perfect square (if the character is one of the two) or not a perfect square (if it's the other). Then they send that number. The decryption then just checks squareness to determine which character it is. That is plausible: The encryption technique is: To send K, send any non-square number; to send X, send any square number. Similarly, to send G, send any square; Y, any non-square; B, any square; Z, any non-square. That would explain why the numbers can be arbitrary large, and the only thing that matters is squareness.
Thus the encryption technique is: map each character to the property of being a perfect square or not. That is a simple and elegant scheme: they hide the character in the squareness of a number. The actual number can be any number with that property, perhaps to add noise. So the decryption just checks if the number is a perfect square and picks accordingly.
In contrast, the mod 3,5,4 rule would mean that for each character they must send a number with a specific residue mod some modulus. That is also possible: For K, send a number divisible by 3; for X, send a number not divisible by 3; etc. But then why choose mod 3 for first position, mod 5 for second, mod 4 for third? That seems less natural. Also, if they used mod 3 for first, they could send any number divisible by 3 for K, any non-divisible by 3 for X. That would also work. But why those moduli? Possibly because 3,5,4 are the number of letters in "KGB"? Actually "KGB" has 3 letters, but then 5 and 4 don't match. Or maybe they are the positions of the letters in the alphabet mod something? Not.
Given the sample, both fit. But maybe we can find a contradiction by considering the constraints: The numbers can be up to 1e9. No other info. Both rules are easy to implement. The problem statement says "Help Sherlock to detect the encryption technique". That implies there is a unique technique to be discovered, not just any that fits sample. To decide, we need to think about typical puzzles: They often use the concept of "perfect squares" because it's a well-known property. Also the letters KGB and XYZ might hint at something: KGB are the first letters of the names of the agents? Not.
Let's see if there's any connection: The word "KGB" has letters K, G, B. The complement set XYZ are the last three letters. The property of being a perfect square might be used to choose between the two triples. But as we saw, the mapping is not consistent: For position 1, square gives X (from XYZ), for position 2, square gives G (from KGB), for position 3, square gives B (from KGB). So it's not simply square -> XYZ.
Maybe the rule is: For each position, if the number is a perfect square, output the letter that appears in the word "KGB" if and only if the position is odd? Position 1 odd: square -> X (not in KGB). Position 2 even: square -> G (in KGB). Position 3 odd: square -> B (in KGB). So not consistent.
Alternatively, maybe the rule is: square -> choose the letter that is later in the alphabet? For A, K(11) and X(24): later is X, square gave X. For B, G(7) and Y(25): later is Y, but square gave G (earlier). So no.
Square -> choose the letter with even position? K=11 odd, X=24 even -> square gave X (even). For B: G=7 odd, Y=25 odd? 25 is odd, both odd, so can't.
Maybe the rule is based on the digit sum? Not.
Given the symmetry of KGB and XYZ, perhaps the encryption technique is: The number is the position of the letter in the alphabet if the letter is from KGB, and it's the position of the letter from XYZ plus something? But the numbers are not positions.
Alternatively, maybe it's as simple as: For each number, if it is a perfect square, the corresponding character is the one that comes second in the given list? For A, list is K,X: second is X, square -> X. For B, list is G,Y: second is Y, but square -> G, not Y. So no.
Maybe the list order is not fixed; maybe they wrote them alphabetically? K and X: K comes before X alphabetically, so first is K, second X. For B: G and Y: G before Y, so first G, second Y. Square gave G (first) for B, and gave X (second) for A, and gave B (first) for C (B comes before Z). So not consistent.
Given the difficulty, I'll search my memory: I recall a problem called "KGB" where the solution was to check if the number is a perfect square. I think I've seen it on CodeChef: maybe "KGB" is a problem from CodeChef's practice. Let's try to simulate: If you Google "KGB encryption technique codechef" maybe you'd find. But I'm ChatGPT offline. However, I'm pretty sure there is a known problem where the answer is based on perfect squares. Also the fact that the sample includes 4 and 16, both squares, and 25, also square, strongly hints at squares. The number 27 is not square, and 26 is not square. So the pattern is clear: all squares map to one set of letters, all non-squares to the other set, though the assignment per position is mixed but deducible from sample.
But we must be careful: For C, both numbers are squares, and both map to B. So if we only had that, we might think squares map to B. For A, we have one square (25) maps to X, one non-square (27) maps to K. For B, square (25) maps to G, non-square (26) maps to Y. So indeed, the mapping from square/non-square to letter is fixed per position. So the rule is consistent.
Thus, to decrypt, we just need to know which letter corresponds to square condition for each position. That is given by the sample? Actually we deduce from the problem statement? The problem statement only gives the possible values, not which corresponds to square. But we can deduce from the sample, but the solution must work for any input, not just sample. So the encryption technique must be that squareness determines the letter. Since the problem asks us to "detect" the technique, we are supposed to infer from the provided info (the sample and the possible values) what the technique is. In a contest, the solver would need to figure out the pattern, likely by noticing that all numbers that are perfect squares correspond to one of the two letters per position, and the non-squares to the other. Since the problem statement might be the only description, the solver must deduce that the encryption uses perfect squares. I think it's the intended solution.
To further confirm, let's think if there is any other property that could be used across all numbers. For instance, the sum of digits? 27 sum=9, 25 sum=7, 4 sum=4. For A, if sum of digits is 9 -> K, 7 -> X? Not a clear rule. For B, 25 sum=7 -> G; 26 sum=8 -> Y. Not constant threshold.
Maybe it's about being a Fibonacci number? 4 is Fibonacci, 16 not, 25 not, 26 not, 27 not. So no.
Perfect squares is the most straightforward.
Also, note that the numbers are up to 1e9, which is 31622^2 approx. So checking perfect squares is trivial.
Thus, I'll implement the perfect square rule.
But we must be absolutely sure about the mapping per position: For A: if square -> X, else K. For B: if square -> G, else Y. For C: if square -> B, else Z.
Let's test with the sample: matches.
Now, consider if we had A=36 (square) -> X; B=36 (square) -> G; C=36 (square) -> B. Output "X-G-B". That seems plausible.
If A=2 (non-square) -> K; B=3 (non-square) -> Y; C=5 (non-square) -> Z. Output "K-Y-Z". That also seems plausible.
Thus the rule is consistent.
Given the problem expects a unique answer for each test case, this rule provides uniqueness.
Now, we should also consider if there might be a trick: The number 1 is a perfect square, so for A, 1 -> X, B: 1 -> G, C: 1 -> B. That's fine.
Edge case: 0 is not in range (>=1).
Thus, solution is clear.
Now, we need to implement for T up to 50000. We'll use fast I/O.
Pseudo:
import sys, math
def is_square(n):
r = int(math.isqrt(n))
return r*r == n
def main():
data = sys.stdin.read().strip().split()
if not data: return
it = iter(data)
t = int(next(it))
out_lines = []
for _ in range(t):
a = int(next(it)); b = int(next(it)); c = int(next(it))
ch1 = 'X' if is_square(a) else 'K'
ch2 = 'G' if is_square(b) else 'Y'
ch3 = 'B' if is_square(c) else 'Z'
out_lines.append(f"{ch1}-{ch2}-{ch3}")
sys.stdout.write("\n".join(out_lines))
if name == 'main':
main()
But wait: The output format in sample: "K-G-B" and "X-Y-B". So hyphens. Good.
Now, confirm that the mapping is correct: In sample first, a=27 not square -> K, b=25 square -> G, c=4 square -> B => K-G-B. Second: a=25 square -> X, b=26 not square -> Y, c=16 square -> B => X-Y-B. Perfect.
Thus, answer.
Before finalizing, consider if there might be any alternative interpretation: The problem says "Print the correct message in format of C-C-C". Possibly they want the characters without hyphens? But sample uses hyphens.
Now, I think this is correct.
However, to be thorough, let's see if there is any possibility that the encryption technique is different, like using the property of being a triangular number or something. But squares fit perfectly.
Given that the problem title or context isn't available, but we are to provide solution, I'll go with perfect squares.
One more check: The problem statement: "Sherlock knows that every number has only 2 possible values which are following:" This could be interpreted as: For each number (i.e., for each of A, B, C), there are only two possible characters it could be. So indeed we need to choose one.
Now, why would perfect squares be the key? Maybe because "KGB" stands for "Kvadrat, G, B"? No.
But perhaps there is a clue: The letters K, X might be chosen because K is the 11th letter, X is the 24th. 11+? 11+?=27? 11+16=27, and 16 is a square. 24+?=25? 24+1=25, 1 is a square. For G (7) and Y (25): 7+?=25? 7+18=25, 18 is not a square. 25 itself is square. For B (2) and Z (26): 2+?=4? 2+2=4, 2 not square; 2+?=16? 2+14=16, 14 not square. So not.
But the numbers themselves: 27 (3^3), 25 (5^2), 4 (2^2), 26 (2*13). Not consistent.
Thus, perfect square detection is the simplest.
I'll produce final answer with explanation.
But the user asked: "The russian intelligence agency KGB make an encryption technique... Help Sherlock to detect the encryption technique of the KGB and tell him the original password." So we need to output the decrypted password for each test case.
Thus, we implement the above.
Potential pitfalls: The input size large, so use sys.stdin.read.
Now, is there any chance that the mapping is reversed for some position? For instance, maybe for B, square -> Y? But sample shows 25 square -> G, so it's G. So mapping is fixed.
Thus, final answer: For each test case, print accordingly.
Now, let's write the solution in Python.
One more nuance: In the problem statement, they say "Print the correct message in format of C-C-C". Could it be that they want the characters in order C first? But sample shows "K-G-B" which corresponds to A-B-C order. So it's A-B-C.
Thus, final.
I'll now produce final answer. ```python
import sys
import math
def is_perfect_square(n: int) -> bool:
"""Return True if n is a perfect square, False otherwise."""
r = math.isqrt(n)
return r * r == n
def solve() -> None:
data = sys.stdin.buffer.read().split()
if not data:
return
it = iter(data)
t = int(next(it))
out_lines = []
for _ in range(t):
a = int(next(it))
b = int(next(it))
c = int(next(it))
code
# decide each character based on square property
first = 'X' if is_perfect_square(a) else 'K'
second = 'G' if is_perfect_square(b) else 'Y'
third = 'B' if is_perfect_square(c) else 'Z'
out_lines.append(f"{first}-{second}-{third}")
sys.stdout.write("\n".join(out_lines))