We need to compute number of bottles needed. There are n participants. Each match: 2 participants, each gets b bottles? Actually statement: "Each match requires b bottles of water for each participant and one bottle for the judge." So per match: 2b + 1 bottles.
We need total number of matches. In a knockout tournament with n participants, the total number of matches is n-1 if it's standard single-elimination. However, here the system is modified: they use some rule to decide how many play each round. Let's understand the process: We have current round with m participants. Find largest power of 2, k, such that k ≤ m. Then k participants compete in matches: meaning they form k/2 matches? Actually k participants compete, but each match is between two participants, so k participants imply k/2 matches if k even? Since k is a power of two, it's even except k=1 (but k=1 only when m=1? Actually if m=1, tournament ends? The process says: when only one participant remains, tournament finishes. So the process continues while m > 1. k is maximal power of 2 ≤ m. If m=1, it's finished. If m>1, k>=2. So k is at least 2. So k participants compete in the current round. Since they compete in matches, presumably they are paired into k/2 matches. The description: "k participants compete in the current round and a half of them passes to the next round, the other m - k participants pass to the next round directly." So exactly half of the k participants (i.e., k/2) pass to the next round, as winners. The losers (the other half of the k) drop out. Meanwhile the m - k participants who didn't compete (since they were not among the k) pass directly to next round. So next round participants = (k/2) + (m - k) = m - k/2.
We need to compute total number of matches across all rounds. Each round, the number of matches is number of competing participants / 2 = k/2.
So total matches = sum over rounds of (k_i/2). This depends on n and the process.
Let's simulate for given n. But perhaps we can derive formula for total matches. Let's consider the process: It is similar to binary representation? We can think: total number of participants eliminated in each round: only the losers from the k competing participants get eliminated, which is k/2 participants eliminated per round. The tournament ends when only one remains. Starting with n participants, total eliminated = n-1. So if we sum the number eliminated per round, we get n-1. Each round eliminates exactly k/2 participants. So sum over rounds of (k/2) = n-1. That is exactly the total number of matches! Because each match eliminates exactly one participant (the loser). So total matches = n-1 always, regardless of the scheduling? Let's check: In standard single-elimination, each match eliminates one, so total matches = n-1. Here it's also elimination tournament, but some participants may skip rounds. However, does each match eliminate exactly one? Yes, each match: two participants, one winner stays, loser out. So each match eliminates exactly one participant. Moreover, participants who skip a round are not eliminated in that round. So total number of matches equals total number of eliminations, which is n-1. But wait: the description says "the other m - k participants pass to the next round directly." So they are not eliminated. So total eliminations across tournament = n-1, and each elimination happens in a match when the participant loses. So total matches = n-1.
But is it possible that some participants get eliminated without playing? No, they only get eliminated by losing a match. So indeed total matches = n-1.
Check examples: Example 1: n=5, matches = 4? But they said total bottles = 20, and per match 5 bottles (b=2 => 22+1=5). 4 matches would be 20 bottles. Yes, matches=4. However they described three rounds: round1: two matches (so 2 matches), round2: one match, round3: one match => total 4 matches. So matches=4 = n-1. Example2: n=8, matches = 7 => 75 = 35 bottles. They got 35 bottles. So it's consistent: total matches = n-1.
Thus bottles = (2b+1)*(n-1).
Now towels: p towels are given to each participant for the whole tournament. So total towels = n * p.
But is there any twist? The description says: "Besides p towels are given to each participant for the whole tournament." So each participant gets p towels, regardless of how many matches they play. So total towels = n * p.
Check examples: Example1: n=5, p=3 => 53=15 towels, matches output 20 15. Example2: n=8, p=4 => 84=32 towels, matches 35. So it fits.
Thus answer: print (n-1)(2b+1) and n*p.
But is there any edge case? n can be 1. Then tournament finishes immediately, no matches. So bottles = (1-1)(2b+1)=0, towels = 1p = p. That seems plausible: no matches, but each participant gets towels. So output 0 p. That's fine.
Thus solution: read n,b,p; compute bottles = (n-1)(2b+1); towels = n * p; print bottles towels.
But wait: The problem statement might be more complicated? It mentions "maximal power of 2 such that k ≤ m" and "half of them passes to the next round". That process indeed leads to total matches = n-1, because elimination count equals n-1. Let's prove: In each round, number of participants reduces by k/2 (since m_next = m - k/2). That means the reduction is exactly the number of matches played that round. Starting from n, after t rounds we have 1 left. So sum of reductions = n-1 = total matches. Yes.
Thus solution is trivial.
Now implement: just compute and output.
Time O(1). Memory O(1).
Write code: use integers.
We'll produce Python solution.
Edge cases: n up to 500, b and p up to 500. Multiplication within 500* (2500+1) = 5001001=500500, safe.
Thus done. ```python
def solve() -> None:
import sys
data = sys.stdin.read().strip().split()
if not data:
return
n, b, p = map(int, data)
bottles = (n - 1) * (2 * b + 1)
towels = n * p
print(bottles, towels)
if name == "main":
solve()