We need to parse the problem: It says Sid says that f is a factor of the total number of animals at the zoo. Jake says that m is a multiple of the same. So both refer to the same total number N (positive integer? Since they counted animals, so N is a positive integer). Sid says: f is a factor of N, i.e., N is divisible by f. Jake says: m is a multiple of N, i.e., m is divisible by N, or N is a divisor of m. So we have f | N and N | m. For there to exist an integer N such that f divides N and N divides m, i.e., f | N | m. That is equivalent to: f divides m? Not exactly: We need existence of integer N such that f | N and N | m. The simplest necessary and sufficient condition: There exists N such that f divides N and N divides m iff f divides m. But careful: If f divides m, we can choose N = f or N = m or any multiple. However, we need both statements to be correct for the same N. If f divides m, we can take N = f (since f | f, and f | m? Wait: Jake says m is a multiple of N: meaning m = k * N, so N | m. So N must divide m. If we take N = f, we need f | m, i.e., f divides m, which is given. And also Sid: f is a factor of N, i.e., f divides N. For N = f, f divides f, true. So if f divides m, then both can be true with N = f. But is there any other restriction? Possibly N must be positive integer? Yes. f and m are positive. So condition is f | m.
But is that sufficient? Let's test examples: Input: 1 4 -> f=1, m=4: 1 divides 4, so CORRECT. Output is CORRECT. 2 3: 2 does not divide 3, so WRONG. Output is WRONG. So seems condition is f divides m.
But we must check nuance: Sid says f is a factor of total number of animals. That means f is a divisor of N. So N mod f = 0. Jake says m is a multiple of N, i.e., m is a multiple, meaning N divides m, i.e., m mod N = 0. So condition for existence of N is that f | m and also N can be any common multiple of f and divisor of m. But the existence is exactly that there is some integer N satisfying f | N and N | m. This holds if and only if f divides m. Because we can always pick N = f (or N = m). However, note that we need N to be a positive integer; it's fine. So condition is f | m.
But is there any hidden constraint? For instance, if f and m are both positive, N must be between f and m? Not stated. They just say f is a factor of the total number of animals, and m is a multiple of the same. It doesn't say that N must be between f and m. So N = f is allowed (since f is a factor of N = f, that means f divides f, correct. And m is a multiple of N: meaning m is a multiple of f, which is given). Similarly N = m is allowed (if f divides m, then f divides m; N = m, f divides N? Need f | m, yes. And m is a multiple of N? m = 1 * m, so m is a multiple of N = m, that's correct because N divides m? Actually for N = m, we require N | m, i.e., m | m, true. So both hold). So indeed f | m is necessary and sufficient.
Thus for each test case we need to check if m % f == 0. Print "CORRECT" if true, else "WRONG". But there is a catch: f and m up to 1e18, t up to 1e5. So use 64-bit integers.
Edge cases: f = 0? Constraints say 1 <= f,m so no zero. So safe.
Thus solution is straightforward.
However, the problem statement might be phrased differently? It says "Sid is saying that f is a factor of the total number of animals at the zoo and Jake is saying that m is a multiple of the same." So we need to determine whether both statements can be true simultaneously. Or maybe we are to verify if both are correct? The phrase "Now, you have to say whether both are correct or not." Means given f and m, we need to output if both are correct. But we don't know N. So we need to decide if there exists an N such that both statements hold. That's exactly our condition. So yes.
Thus answer: For each test case, if m % f == 0 then CORRECT else WRONG.
But maybe there is a twist: Sid says f is a factor of N, meaning N = k * f. Jake says m is a multiple of N, meaning m = l * N. Then N = m / l. Combining: f divides m / l, and l is some positive integer? Actually, if both statements are correct, then N is determined as the actual number of animals. But we don't know N. So we are asked: Given f and m, is it possible that both are correct? That is exactly existence of integer N satisfying conditions. As argued, it's possible iff f divides m.
But check: Could there be any scenario where f divides m, but still both cannot be correct? For example, if f = 2, m = 4. Then N could be 2 (Sid: f=2 factor of 2? Yes, 2 divides 2. Jake: m=4 is a multiple of 2? Yes, 4 = 2*2). So correct. If f = 4, m = 2? Then f doesn't divide m, so no. So condition holds.
Thus trivial solution.
But note: The problem's title? "Zoo" maybe from some contest. Could be trick: The statements "f is a factor of the total number" and "m is a multiple of the same" might be misinterpreted: "m is a multiple of the same" could be interpreted as "m is a multiple of f"? But it says "of the same", i.e., same total number of animals. So it's as we used.
Thus answer: Check if m % f == 0.
But wait: The problem might ask: Given f and m, we need to output whether both statements can be true about the same number. Could there be a scenario where f > m, but f | m is impossible because f > m and positive integer division only if f <= m? If f > m, then f cannot divide m (unless m=0 but m>=1). So condition fails. Example: f=10, m=5 -> no. So output WRONG. That seems fine.
Thus algorithm: For each test case: read f, m; if m % f == 0: print "CORRECT"; else print "WRONG".
Complexities: O(t) time, O(1) space.
Given t up to 1e5, easy.
Now, we should consider large I/O: Use fast I/O in C++.
Also, note that we need to output exactly "CORRECT" or "WRONG".
Now, check sample: Input: 2\n1 4 -> 4%1=0 -> CORRECT. 2 3 -> 3%2=1 -> WRONG. Matches.
Thus final answer.
But let's think if there could be any nuance about N being the same? Both statements are about the same N. So we need f|N and N|m. That implies f|m. However, is that sufficient? Yes, because we can set N = f (or N = m, or any N that is a multiple of f and divisor of m). But existence of such N requires that there is at least one integer N with f|N and N|m. That is equivalent to the existence of an integer k such that N = kf and N divides m. That is, kf | m. That means m must be divisible by kf. For existence of some k, we need that there exists some integer k such that kf divides m. This is equivalent to: m must be divisible by f? Not exactly: If f divides m, then choose k=1, N=f, then N divides m? f divides m? Yes, that means N|m. So k=1 works. So f|m suffices. Conversely, if there exists some k such that kf divides m, then in particular, f divides (kf), and (kf) divides m, so f divides m? Because if (kf) | m, then m = t * (kf) = (tk)*f, so f divides m. So f|m is equivalent to existence of some k (specifically k=1). So condition is f|m.
Thus our reasoning is solid.
Thus answer: simple modulo check.
Now, let's write solution in Python as required? The user asked to "Write the answer in C++". Actually they said: "You are a competitive programming AI. Provide the solution in C++". So we need to produce C++ code.
But the conversation: The problem is given, we need to produce answer. I'll produce code with fast I/O, handle up to 1e5 test cases.
Potential pitfalls: Use long long for 10^18.
Now, check for overflow: Only mod operation, fine.
Now, produce final answer.
But wait: The problem statement includes "Tips: Print “CORRECT”(without quotes) if both Sid and Jake are correct, print “WRONG”(without quotes) otherwise." So we must print exactly those strings.
Edge Cases: f = 1 always divides m, so always CORRECT. f=m also always CORRECT. So that's fine.
Now, write code.
Implementation:
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
long long f, m;
cin >> f >> m;
if (m % f == 0) {
cout << "CORRECT\n";
} else {
cout << "WRONG\n";
}
}
return 0;
}
That's it.
But ensure that if f=0? Not possible.
Thus final answer.
But the problem may have been intended to be solved with GCD or something? Possibly there is nuance: "f is a factor of the total number" means f is a divisor. "m is a multiple of the same" means m is a multiple. So they might be both correct if f divides N and N divides m, which is equivalent to f divides m. Yes.
Thus final solution.
Now, let's produce final answer: Provide explanation and code.
Given the user request: "Write the answer in C++", so just code? Probably they want solution code. I'll include short explanation as comment.
But as a ChatGPT response, I'll give a brief explanation and the C++ code.
Thus final. ```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
long long f, m;
cin >> f >> m;
// Both statements are true iff there exists an integer N such that
// f | N and N | m, which is equivalent to f | m.
if (m % f == 0) {
cout << "CORRECT\n";
} else {
cout << "WRONG\n";
}
}
return 0;
}