We need to solve a problem: Given two integers A and B (1 ≤ A, B ≤ 100). We have two tins, one with A cookies, one with B cookies. Snuke cannot open the tins, meaning he can only give away entire tins as they are. So he can give either the first tin (A cookies), the second tin (B cookies), or both tins together (A+B cookies) to his three goats. He must give cookies to his three goats so that each goat gets the same number of cookies. That implies the total number of cookies given must be divisible by 3, and also the way the tins are given must be such that they can be partitioned into three equal groups? Wait: The description: "He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins)." It says "He can thus give A cookies, B cookies or A+B cookies to his goats". That phrasing is ambiguous: does it mean that he gives the cookies from the tins to the three goats, but he can only give them as whole tins? For example, he could give the tin of A cookies to the goats (meaning he opens it? Actually "he cannot open the tins" suggests that he cannot take cookies out of the tins individually; he must give the tins as they are to the goats? Let's parse: "He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins)." So the idea: He cannot open the tins to take out individual cookies, so his only options are to give the goats the whole tins. But there are three goats, so he could give one tin to one goat, the other tin to another goat, and possibly give both tins together to a goat? But it says "he can thus give A cookies, B cookies or A+B cookies to his goats". That sounds like the total amount of cookies he gives to the goats can be A, B, or A+B. But then he has three goats; does he give all cookies to all three? Possibly he gives the entire set of tins he decides to give to the three goats, and then the goats will split them equally? But the problem states: "determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies." That suggests that Snuke decides which tins to give (maybe giving some tins to some goats), and each goat ends up with some number of cookies, and we need all three numbers equal.
But the phrase "He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins)" might be interpreted as: He can either give the first tin (which contains A cookies) to the goats, or give the second tin (B cookies) to the goats, or give both tins (A+B cookies) to the goats. But he has three goats, so if he gives just one tin, does that mean that tin's cookies are divided among the three goats? Or does it mean he gives the tin to one goat, and the other goats get nothing? Usually, "give cookies to his three goats" implies each goat receives some cookies. So if he gives just one tin containing A cookies, then the three goats must split those A cookies equally? But he cannot open the tin, so he cannot split the cookies. That would be contradictory.
Let's examine sample: Input: 4 5 -> Output: Possible. How can that be? If he gives both tins (A+B=9 cookies) to the goats, then total is 9, which is divisible by 3? 9/3=3, so each goat could get 3 cookies. But can he split 9 cookies into three groups of 3 without opening the tins? He cannot open the tins, so the cookies are inside tins; the tins themselves are separate containers. Maybe he gives the tins to goats, each goat may get one tin, or both tins to one goat, etc. The goal is that each goat has the same number of cookies. So we need to assign the tins (each tin is a container with some cookies) to the goats in such a way that the total cookies per goat are equal. Since tins cannot be opened, each goat gets some whole tins, and the cookies inside each tin are consumed by that goat (or shared? no, each goat gets the tin, and presumably gets to eat the cookies inside). So each goat gets some integer number of tins (0, 1, or 2 maybe, but you can't give the same tin to multiple goats). So essentially we have two items: one with value A, one with value B. We need to partition these two items among three goats, such that each goat's total is the same. But we only have two items to allocate to three goats. Unless we can also choose not to give some tins? It says he can give A cookies, B cookies, or A+B cookies to his goats. That might mean he can decide to give none? Actually "give A cookies" suggests he gives the tin containing A cookies to the goats (i.e., he uses that tin), but then what about the other tin? It might be that he could also choose not to give a tin. But the phrase "he can thus give A cookies, B cookies or A+B cookies to his goats" seems to indicate that the total number of cookies he gives is either A, B, or A+B. That suggests that he can either give only the first tin, only the second tin, or both tins. So he must give at least one tin (can't give zero cookies because then the goats get nothing? But zero would be divisible by 3? Actually 0 works if all get 0, but constraints are A,B>=1, but giving zero might not be allowed. Usually, he's giving cookies, maybe he can give none? But the phrase suggests the options are A, B, or A+B; not zero. So he must give exactly one tin or both.
Now, given that he gives a set of tins (either one tin or two), how are the cookies distributed among three goats? Since he cannot open tins, the only way to distribute is to give whole tins to goats. But if he gives only one tin, then that tin must be given to one goat, leaving the other two with zero. That would not be equal unless A=0, but A>=1. So not possible. If he gives both tins, then he has two tins to distribute among three goats. Could he give both tins to a single goat? Then that goat gets A+B, the other two get 0, not equal unless A+B=0. Could he give one tin to goat1 and the other to goat2, and none to goat3? Then totals are A, B, 0; equal only if A=B=0. So not possible. So distribution of whole tins without opening them seems impossible to get all three goats equal, unless we can split the cookies within the tins? But the problem says he cannot open the tins, so he cannot break the tins. So there must be another interpretation.
Perhaps the interpretation is: Snuke can give the goats the cookies from the tins, but he cannot open the tins, meaning he cannot take some cookies out; he can only give the entire tin to the goats, but the goats themselves could open the tin? Actually if he gives a tin to the goats, the goats can open it and eat the cookies. But the distribution is done by Snuke: he gives cookies to each goat. If he cannot open the tins, he can't give partial cookies; he can only give whole tins to individual goats. So again, distribution with two tins to three goats cannot yield equal numbers unless the numbers align in a specific way that allows dividing the two tins' cookies among three goats by perhaps sharing? No.
Maybe the intended meaning: He can give cookies to his three goats from the two tins, but he cannot open the tins, so he can only hand over the tins themselves. However, he can give multiple tins to a single goat, or give one tin to multiple goats? No.
Let's re-read the problem statement precisely as might be from AtCoder (I think this is from AtCoder ABC 105 A? Actually there's a problem "Snuke's Cookies"? Not sure). Let me search memory: There is an AtCoder problem "Snuke's Favorite Numbers" or something. But the description: "Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies." I recall an AtCoder problem: It might be from AtCoder Beginner Contest 068? No.
Actually, I think it's from AtCoder ABC 118 A? Not that. Let me think: There is an AtCoder problem: "B - 1 21" no.
Maybe it's from AtCoder ABC 100 A? That is about cake. Not.
I can try to deduce from sample: A=4, B=5 => output "Possible". How could that be possible? If he gives both tins (total 9), then each goat can have 3 cookies. But to achieve that, he must split the 9 cookies equally. Since he cannot open the tins, can he split 9 cookies? The tins contain 4 and 5 cookies respectively. He could open the tins? The statement says he cannot open the tins. So perhaps he gives the tins to the goats, and the goats themselves can open and share? But the problem is about Snuke giving cookies; perhaps he can give the cookies by presenting the tins, and the goats will then distribute among themselves equally? The question: "determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies." So Snuke wants to give cookies such that each goat ends up with the same number. He can only give whole tins, but the goats might be able to open them and split the cookies? But then Snuke's giving is just the tins, and the goats can distribute the cookies among themselves. If the goats can open tins and split cookies arbitrarily, then as long as the total number of cookies is a multiple of 3, they can each get the same. However, the constraint is that Snuke cannot open the tins, but he can give the tins to the goats. If the goats can open them, then the distribution among goats is not constrained by the indivisibility of tins because they can open and split. In that case, the only condition is that the total number of cookies given (which is either A, B, or A+B) is divisible by 3. That matches the sample: 4+5=9 divisible by 3, so Possible. But what about giving only one tin? If total = A divisible by 3, also possible. But can he give just one tin? The statement says he can give A cookies, B cookies, or A+B cookies. So he can choose to give only the tin of A cookies, or only the tin of B cookies, or both. So condition for possibility: either A % 3 == 0, or B % 3 == 0, or (A+B) % 3 == 0. But is that correct? Let's test with another example: Input 1 1 -> output Impossible. Under this condition: 1%3=1, 1%3=1, (1+1)=2%3=2, none divisible by 3, so Impossible. That matches. Another test: A=3, B=5 -> 3%3=0 -> Possible. That seems plausible. But is there any other nuance? Could there be a scenario where A%3=0 but he cannot give only that tin because maybe he must give both? The statement explicitly says "He can thus give A cookies, B cookies or A+B cookies to his goats". So yes, he can choose to give only the tin of A cookies. So if A is multiple of 3, he can give that tin, and the goats (presumably they can open it and split the cookies equally). But wait: if he gives only one tin, then there is only one tin, which contains A cookies. But the three goats need to split those cookies equally. If the goats can open the tin and share, they can split A into three equal parts if A is divisible by 3. So it's fine.
But then, what about the fact that he cannot open the tins? The phrase "he cannot open the tins" might be to indicate that he cannot take out some cookies from a tin to give to the goats individually; he can only give the whole tin. But if he gives the whole tin to the goats, then the goats collectively receive the tin. The tin is a container. After receiving the tin, the goats could open it and divide the cookies. So the constraint that he cannot open the tins doesn't prevent the goats from opening them; it only restricts his actions. So that interpretation is consistent.
Let's examine if any AtCoder problem matches this exactly. I recall a problem from AtCoder Beginner Contest 067 A? Actually ABC 067 A is "Sharing Cookies". The problem: "Snuke is giving cookies to his three goats. He has two cookie jars. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies, or A+B cookies to his goats (he cannot open the jars). Determine if it is possible that each goat gets the same number of cookies." That's exactly the problem? The known solution: check if any of A, B, A+B is divisible by 3. That is typical. Yes, I think it's from ABC 067 A "Sharing Cookies". Actually ABC 067 A is "Sharing Cookies"? Let's check: ABC 067 A is "Sharing Cookies" indeed: The problem statement: "Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies, or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies." Yes, that's the exact problem. The solution: if A%3==0 or B%3==0 or (A+B)%3==0, print "Possible", else "Impossible". So our deduction is correct.
But note: There might be a nuance: "he cannot open the tins" might also imply that he cannot give a partial tin, but he can give the tin(s) to the goats. The goats are three, so if he gives one tin, to which goat does he give it? Possibly he gives the tin to the goats collectively, meaning the tin is placed in front of them and they share? That would be a bit odd, but it's a puzzle.
Given the typical solution, the problem is straightforward.
Thus the algorithm: read A and B; if A%3==0 or B%3==0 or (A+B)%3==0, print "Possible", else "Impossible".
But wait, there is also possibility that giving A+B (both tins) might involve the goats sharing two tins; again the total is A+B. So the condition is as above.
Edge cases: A and B between 1 and 100, so fine.
Thus we need to implement that.
But maybe there is another interpretation: perhaps Snuke must give each goat some cookies, but he cannot open tins, so he must give each goat some whole tins (maybe zero, one, or two). But then the condition becomes: can we assign the two tins to three goats such that each goat gets same total? That would require that the sum of cookies from the tins given is divisible by 3 and also that we can partition the tins into three groups with equal sum. But we only have two items. It's impossible to partition two items into three groups with equal positive sums unless the items are zero. So the only possibility would be to give zero tins to all, but then each gets 0, but constraints A,B>=1, and giving zero might not be an option. The problem says he can give A, B, or A+B cookies. So giving zero is not an option. So that interpretation would always be impossible, contradicting sample. So our first interpretation is correct.
Thus the solution is trivial.
But let's be thorough: Could there be a scenario where he gives the tins to the goats in a way that some goats get whole tins and others get nothing, but the ones that get something share with others? That's not described.
Given the simplicity, we implement.
Now, the user wants a solution. They likely want code in a language, but the problem statement is generic. Usually these problems are solved in C++/Python/Java. We can provide Python code.
But the user query: "Snuke is giving cookies ..." and they want output. They didn't specify language. Since it's a coding problem, we should output a solution in a common language like Python.
Thus the answer: We need to check if any of A, B, A+B is divisible by 3. Print "Possible" if true, else "Impossible".
Now, before finalizing, let's test more cases:
-
A=2, B=2 -> 2%3=2, 2%3=2, sum=4%3=1 -> Impossible. But could there be a way: give both tins, total 4, not divisible by 3 -> cannot split equally among 3 goats. So Impossible.
-
A=3, B=4 -> 3%3=0 -> Possible. Could he give only the A tin? Yes, give the tin with 3 cookies; the goats share, each gets 1. So Possible.
-
A=100, B=100 -> 100%3=1, 100%3=1, sum=200%3=2 -> Impossible. That seems correct.
Thus it's fine.
We should provide the code with input reading and output.
Now, one more nuance: The problem might be from AtCoder and the output must be exactly "Possible" or "Impossible" with correct capitalization.
Thus solution.
But the user might also want an explanation. The instruction: "Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies." And then they provide input format.
Thus I'll provide a solution in Python.
I'll write:
def main():
import sys
A, B = map(int, sys.stdin.read().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
print("Possible")
else:
print("Impossible")
if name == "main":
main()
That's it.
Now, maybe they want to consider that he can give "A cookies, B cookies or A+B cookies" means the total number of cookies he gives is exactly one of those; but can he give, say, 0 cookies? Not mentioned. So no.
Thus final answer: Python code as above.
But we might need to present it as a solution. The user says: "Snuke is giving cookies to his three goats. ... Input ... Output ..." It might be that they are pasting the problem description and asking for a solution. So we should provide the answer.
Thus the final. ```python
import sys
def main():
A, B = map(int, sys.stdin.read().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
print("Possible")
else:
print("Impossible")
if name == "main":
main()