Skip to content
TheChatArchiveThe Chat Archive
DeepSeekDeepseek v3.2· deepseekHugging Face Frontier Reasoning Traces

The last stage of Football World Cup is played using the play-off system. There are n…

  1. User

    The last stage of Football World Cup is played using the play-off system.

    There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the fourth, the fifth — with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.

    Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet. Input

    The only line contains three integers n, a and b (2 ≤ n ≤ 256, 1 ≤ a, b ≤ n) — the total number of teams, and the ids of the teams that Arkady is interested in.

    It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.

    Output

    In the only line print "Final!" (without quotes), if teams a and b can meet in the Final.

    Otherwise, print a single integer — the number of the round in which teams a and b can meet. The round are enumerated from 1.

    Examples

    Input

    4 1 2

    Output

    1

    Input

    8 2 6

    Output

    Final!

    Input

    8 7 5

    Output

    2

    Note

    In the first example teams 1 and 2 meet in the first round.

    In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.

    In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round.

  2. DeepSeek Assistant

    We need to determine the earliest round where two teams a and b could possibly meet in a single-elimination tournament structured as described: each round, teams are sorted by ID (low to high) and paired (1st vs 2nd, 3rd vs 4th, etc). The tournament has n teams initially, and we assume that in each round, the number of teams is even. The tournament proceeds with elimination until one champion. The question: determine which round teams a and b could meet in (i.e., if both win all prior rounds, they would meet in some round; we need to find the round number). If they can meet only in the final, output "Final!". Otherwise output the round number.

    This is a classic problem: given a bracket where seeds are arranged in order (not random but fixed based on IDs). For two teams to meet in round k, they must be in the same "segment" of the bracket that merges at that round. The tournament is basically a full binary tree where leaves are teams in order. The round numbers: Round 1 has n/2 games, Round 2 has n/4, ... Final has 1 game.

    We can simulate the tournament: In each round, we pair adjacent teams in the sorted list. Winners progress. So if we have IDs sorted, the bracket is predetermined: it's a perfect bracket for a power of two, but n may not be a power of two? However constraints: n is such that each round has even number of teams; that implies n can be any number that satisfies that property: n even, n/2 even, etc. Actually it says: It is guaranteed that n is such that in each round an even number of team advance. That implies that n is a power of two? Let's check: For each round, the number of teams at start must be even. So n even. Then after round 1, n/2 teams remain; they also must be even for round 2; so n/2 even => n divisible by 4. Continue: So n must be a power of 2. Because to have even number of teams at every round, the count must be halved each time and remain even until final (1). That forces n = 2^k. Indeed, tournament sizes in elimination with byes would have odd numbers sometimes, but here they say "It is guaranteed that in each round there is even number of teams." So n is such that all rounds have even number, meaning that n is a power of two. The examples: 4,8. The constraint n up to 256 = 2^8. So yes, n is a power of two.

    Thus we have a standard single-elimination bracket with seeds in increasing order: team IDs correspond to positions 1..n in the bracket. So we can think of the tournament bracket as a full binary tree. Two teams meet in round r if the distance between their positions in the tree is such that they would meet at that round. More formally, the round when they meet (if both win) is determined by the highest round where they are in the same half of size 2^r. Actually if we number rounds from 1 (first round) to final round = log2(n). In round 1, pairs are (1,2), (3,4), (5,6), etc. To meet in round 1, they must be paired together: i.e., a and b must be consecutive numbers with a odd, b = a+1, or vice versa. But also note that order matters: In each round they sort by ids, so pairing is always between adjacent positions. So if a and b are (1,2) they meet round 1; (2,3) actually 2 and 3 are not paired together because first round pairs (1,2) and (3,4). So 2 and 3 are in different pairs; they could only meet later if they both win. So the condition for meeting in round r is that after dividing the bracket into blocks of size 2^r, the two teams are in the same block, but in different sub-blocks of size 2^(r-1). Actually: Consider the tournament as a binary tree with leaves in order. The first round merges pairs of leaves (size 2 blocks). The second round merges two adjacent pairs (size 4 blocks), and so on. So two teams meet in round k if they are in the same block of size 2^k, but in different sub-blocks of size 2^(k-1). That is a typical solution. So we can compute: Let x = a-1, y = b-1 (zero-indexed). For round r from 1 to log2(n), check if floor(x / 2^(r-1)) != floor(y / 2^(r-1)) but floor(x / 2^r) == floor(y / 2^r). Actually better: They meet in round r if ( (a-1) // (1<<r) ) == ( (b-1)//(1<<r) ) but ( (a-1)//(1<<(r-1)) ) != ( (b-1)//(1<<(r-1)) ). Alternatively, we can compute the smallest r such that they are in the same half of size 2^r. That is essentially the round number of meeting if both win. Actually the earliest round they could meet is the round where they are placed in the same bracket segment of size 2. But if they are in the same pair (size 2) they meet round 1. So we can compute the round number as: r = 1 + floor( log2( (a-1) xor (b-1) ) ). This is known: In a standard binary tree bracket with seeds in order, the round where two seeds meet is determined by the highest bit where they differ? Let's think: In a binary tree, leaves indexed from 0 to N-1. The depth at which their LCA is located is related to the common prefix. Actually if we number leaves in binary of length k = log2(N). Two leaves with indices i and j will meet at the round corresponding to the level where the highest bit difference occurs? More precisely, the round number (starting from 1) is: k - (length of common suffix? Wait, we need to map rounds.

    Alternate method: Simulate the tournament pairing: In each round, we reduce the list by keeping only winners. If we assume a and b win all their matches, we can simulate their positions as the tournament progresses. But easier: The indices a and b will be in the same group of size 2^r at round r if floor((a-1)/2^(r-1)) == floor((b-1)/2^(r-1))? Actually need to think about which round they could meet.

    Let's define N = n. Round 1: groups of size 2: (1,2), (3,4), (5,6), ... So if a and b are in the same group of size 2, they meet in round 1. So condition: ceil(a/2) == ceil(b/2)? Actually group number for round 1: group = (a+1)//2 (integer division rounding up). For a and b to be paired in round 1, they must have the same group number. That means (a+1)//2 == (b+1)//2. That's equivalent to floor((a-1)/2) == floor((b-1)/2) and also a and b are distinct, but they would be paired only if they are consecutive with the smaller odd. If they are both in same group of size 2, that automatically means they are the two members of that group, so they meet round 1. So condition for meeting in round 1: (a+1)//2 == (b+1)//2.

    Now, if they are not in same group in round 1, then they could meet later. In round 2, the winners from each pair form a new list. The winners' "identities" are unknown but we assume a and b win, so they advance. In the new list for round 2, each winner is placed in a slot corresponding to the group they came from. The grouping in round 2: The winners of groups (1,2) and (3,4) play, winners of (5,6) and (7,8) play, etc. So the groups for round 2 are of size 4 (i.e., original block of 4 teams). Two teams a and b will meet in round 2 if they are in the same block of size 4 but not in the same sub-block of size 2. That is: ceil(a/4) == ceil(b/4) but ceil(a/2) != ceil(b/2). Similarly, round r: they meet if ceil(a / 2^r) == ceil(b / 2^r) but ceil(a / 2^{r-1}) != ceil(b / 2^{r-1}).

    We need to find the smallest r such that ceil(a / 2^r) == ceil(b / 2^r). Actually, if they meet in round r, that means that in round r, they are in the same group of size 2^r, but in the previous round they were in different groups of size 2^{r-1}. So the meeting round is the smallest r such that ceil(a / 2^r) == ceil(b / 2^r). Because as r increases, the groups get larger; eventually at r = log2(n), ceil(a/n) = 1 == ceil(b/n) = 1. So there is always some r where they become equal. The smallest r where they are equal is the round where they could meet. Wait check: For round 1, groups size 2, ceil(a/2) == ceil(b/2). If this holds, they meet in round 1. If not, then for round 2, groups size 4, ceil(a/4) == ceil(b/4)? Possibly yes, if they are in the same block of 4 but not same block of 2. But could they be in same block of 4 but also same block of 2? That would mean they meet earlier, so the smallest r is indeed the meeting round. But careful: If they are in same block of 4 but also same block of 2, then ceil(a/2) == ceil(b/2) already holds, and the smallest r would be 1. So that's consistent. So we can compute r as the smallest positive integer such that ( (a-1) // (1<<r) ) == ( (b-1) // (1<<r) ), if using zero-indexed integer division? Let's verify.

    Using ceil: ceil(a/2^r) = floor((a-1)/2^r) + 1. So equality of ceil is equivalent to floor((a-1)/2^r) == floor((b-1)/2^r). So we can compute with zero-indexed floor division.

    Thus meeting round = smallest r >=1 such that floor((a-1) / 2^r) == floor((b-1) / 2^r). Since floor((a-1)/2^r) reduces to the index of the block at that level. Actually, as r increases, the blocks get larger, so the condition becomes easier to satisfy. At r = log2(n), both floor((a-1)/n) = 0, equality holds. So there is always such r. So we can iterate r from 1 to log2(n) and find first where equality holds.

    Alternatively, we can compute the XOR method: Let x = a-1, y = b-1. Consider the binary representation of length k = log2(n). The round number (starting from 1) is the position of the most significant bit where x and y differ, counted from the LSB? Actually, think: Two teams meet at the round corresponding to the level of the tree. The tree's leaves are indexed 0..N-1. The internal nodes correspond to merging two subtrees. The LCA (lowest common ancestor) of two leaves is at depth (k - (the number of leading common bits? Actually, if we think of leaf indices as binary numbers of length k, the tournament structure is a standard knockout bracket where the first round pairs leaves that differ only in the least significant bit (i.e., indices where only last bit differs). In the second round, winners from pairs that differ in the second least significant bit, etc. Indeed: In a perfect bracket with seeds in order, the matches are determined by flipping bits from LSB upward. So two seeds i and j will meet at round r if the highest bit position (starting from 0 as LSB) where they differ is r-1? Let's derive: Suppose N=8, indices 0..7 binary: 000,001,010,011,100,101,110,111. Round 1: pairs (0,1) differ in bit0; (2,3) differ bit0; (4,5) differ bit0; (6,7) differ bit0. Round 2: winners from (0,1) and (2,3) meet; they correspond to indices where bits0 may vary but they share bits1? Actually the group of size 4: indices 0-3 have same bits2? Wait, for 8: indices 0-3 have msb=0 (since 0-3 is 00*, 01*? Actually 3 bits: bit2 is most significant. 0-3: bit2=0, bit1 and bit0 vary. In round 2, the two pairs from each half of the 4-group are combined. The condition to meet in round 2: they must be in same group of 4 but different groups of 2. That means that they share the same bits from position 2 down to bit1? Let's think: Group of 4: determined by the top k-2 bits? Actually for N=8, k=3. Group of size 4 = 2^{2} leaves: determined by the most significant bit (bit2) and the next bit (bit1)? Actually to be in same block of 4, they must have the same values for the most significant 1 bit? Let's see: indices 0-3: binary 000,001,010,011. The top two bits (bits2 and bit1) for these are: 00,00,01,01? That's not the same; 0: bits2=0, bit1=0; 1: 0,0; 2: 0,1; 3:0,1. So within block 0-3, bit2 is always 0, but bit1 can be 0 or 1. Actually the block of 4 (first block) comprises indices with floor(i/4) = 0. That is top k-2 bits? Since 4=2^{2}, floor(i/4) is determined by bits beyond the lower 2 bits. For i in [0,3], floor(i/4)=0. That is essentially the bits from position 2 (the third bit) onward (since i/4 = i >> 2). So for two indices to have same floor(i/4), their bits from position 2 upward must be equal. For round 2 meeting, we need floor(i/4) equal but floor(i/2) different. floor(i/2) corresponds to shifting by 1. So equality of floor(i/2) means bits from position 1 upward equal. So floor(i/2) different means that at bit1 they differ. So the highest bit where they differ among bits below the top (starting from LSB) would be bit1? Actually the condition for meeting in round r is that the top k-r bits are equal, but the next bit (the (k-r)th bit, counting from 0 as LSB?) Let's define positions from LSB=0 to MSB=k-1. In a bracket, round 1 depends on bit0; round 2 depends on bit1; round 3 depends on bit2; etc. Actually, for N=8, round 3 (final) depends on bit2: two finalists are from halves: indices 0-3 vs 4-7 differ in bit2. So two teams meet in round r if their indices differ at bit (r-1) and have identical higher bits (bits r to k-1). Because if they differ at a lower bit, they would meet earlier? Let's test: a=1 (0-index 0) and b=2 (0-index 1): binary 000 and 001 differ at bit0; higher bits (bits1 and 2) are same (00). So they meet in round 1? According to this, difference at bit0 => round 1. That matches. a=1 (0) and b=3 (2): binary 000 and 010 differ at bit1 (since bit0: 0 vs 0? Actually 000 and 010: bit0: 0 vs 0; bit1: 0 vs 1; higher bits (bit2): 0 vs 0). According to rule, they differ at bit1, so round 2. Indeed they are in same block of 4 (0-3) but different sub-blocks: (0,1) vs (2,3) => meet in round 2 if both win. a=1 (0) and b=5 (4): binary 000 and 100 differ at bit2; round 3 (final). So that matches: round number = index of highest bit where they differ (from LSB=0) + 1. But careful: If they differ at multiple bits, the highest (most significant) difference determines when they meet? Actually consider a=1 (0) and b=6 (5? Let's compute: 0:000, 6:110? 6 is 110 binary. They differ at bit2 (1 vs 0?), 0: 0, 6:1 -> bit2 differ, bit1 also differ (0 vs1), bit0 differs (0 vs0? Actually 0:0, 6:0? 6 binary 110, bit0=0, so bit0 same? Wait 0:000, 6:110: bit2:0 vs1 differ; bit1:0 vs1 differ; bit0:0 vs0 same. The highest bit difference is bit2 (since bit2 is more significant). According to the rule above, they would meet in round 3 (final). Let's check manually: teams 1 and 6 in an 8-team bracket. IDs: 1,2,3,4,5,6,7,8. Pairings: round1: (1,2), (3,4), (5,6), (7,8). If both win, winners: 1 beats 2; 6 beats 5 (since 5 vs 6, 6 wins). Then round2: Now we have winners from (1,2) = 1; from (3,4)=3 or 4; from (5,6)=6; from (7,8)=7 or 8. The pairing for round2: first winner (team1) vs second winner (winner of (3,4)), third winner (team6) vs fourth winner (winner of (7,8)). So 1 and 6 are in opposite halves of the bracket: they would only meet in final (round3). So indeed they meet in final. So the highest bit difference (most significant) corresponds to final round? Wait, in the example with a=1 (0) and b=3 (2) (binary 000 vs 010), they differ at bit1 and also bit0 is same. The highest difference is bit1, and they meet in round 2. That matches: round = highest differing bit index + 1? Actually bit index: bit0 = LSB -> round1; bit1 -> round2; bit2 -> round3. So round = index of highest differing bit (0-based from LSB) + 1. But check a=1 and b=2: differing bit0 only, highest differing bit = bit0 => round1. Good. a=1 and b=5: 0 vs 4 (100) differ at bit2 only (bit1 and bit0 same if 5? Actually 5 is 101, 1 is 001? Wait I'm mixing 0-index and 1-index. Let's use 1-indexed IDs. Usually the formula with 0-indexed (subtract 1) works. For IDs a=1 (i=0) and b=5 (i=4). 0:000, 4:100 => differ at bit2, same lower bits? bit2:0 vs1, bit1:0 vs0, bit0:0 vs0. Highest differing bit = bit2 => round3 = final. So correct.

    But is it always the highest differing bit? Consider a=2 (i=1) and b=3 (i=2). 1:001, 2:010. They differ at bit0? Actually 1=001, 2=010. Bits: bit2:0 vs0; bit1:0 vs1; bit0:1 vs0. They differ at both bit1 and bit0. Which is the highest? bit1 is higher (more significant) than bit0. Highest differing bit = bit1 (index1) => round2. But in actual bracket: IDs 2 and 3 are in round1? Let's see: In an 8-team bracket, teams 2 and 3 are not paired together in round1; they are in groups (1,2) and (3,4). So they are in different initial pairs. To meet, both must win: 2 would beat 1, 3 would beat 4. Then in round2, winners: team2 and team3 would be paired? Let's simulate: round1 winners: (1,2) -> winner 2? Actually if both win, 2 beats 1, and 3 beats 4. Then round2 pairings: first winner (team2) vs second winner (team3) because winners are sorted by original IDs? Actually after round1, we have list of winners. The winners are placed in order of the groups they came from: from group1 (teams1,2) winner is either 1 or 2; from group2 (teams3,4) winner is either 3 or 4; group3 (5,6); group4 (7,8). After round1, the winners list: [winner1, winner2, winner3, winner4]. In round2, they pair: winner1 vs winner2, winner3 vs winner4. So if winner1=2 and winner2=3, then indeed they meet in round2. So they meet in round2, not round1. So round2 is correct. So highest differing bit (bit1) yields round2.

    Now consider a=4 (i=3) and b=5 (i=4). 3:011, 4:100. Bits: bit2:0 vs1, bit1:1 vs0, bit0:1 vs0. Highest differing bit = bit2 -> round3 final. In bracket: teams4 and5 are in round1? Pairings: (3,4) and (5,6). So they are in different groups, not meeting round1. If both win: 4 beats3? Actually group (3,4) winner could be 4; group (5,6) winner could be 5. Then round2: winners from groups2 (3,4) and 3 (5,6) are in order: after round1, winners: [w1 from (1,2), w2 from (3,4), w3 from (5,6), w4 from (7,8)]. Round2 pairings: w1 vs w2, w3 vs w4. So w2 (team4) and w3 (team5) are not paired together; they would only meet in final if both win their round2 matches. So round3 final. So correct.

    Thus, the meeting round = index of highest bit where (a-1) xor (b-1) is 1, counting from 0 as LSB, then round = that index + 1. Alternatively, round = floor(log2( (a-1) xor (b-1) )) + 1.

    We also need to output "Final!" if the meeting round is the final round, i.e., round = log2(n). Since final round number is log2(n). Because with n teams, number of rounds = log2(n). For example n=8 -> 3 rounds; final is round3. So if computed round == log2(n), output "Final!" else output the round number.

    Let's test with examples:

    Example1: n=4, a=1,b=2. (a-1)=0,(b-1)=1, xor=1, log2(1)=0, round=1. log2(n)=2 (since 4->2 rounds). round=1 not equal 2 -> output 1. matches.

    Example2: n=8, a=2,b=6. (2-1)=1,(6-1)=5, xor=4 (binary 100), log2(4)=2, round=3. log2(8)=3 -> round==3 -> Final! matches.

    Example3: n=8, a=7,b=5. (7-1)=6,(5-1)=4, xor=2 (010), log2(2)=1, round=2. log2(8)=3 -> round=2 not final, output 2. matches.

    Thus solution works.

    But note: The problem statement says: "Determine, in which round the teams with ids a and b can meet." It might be that they want the round number if they meet before final, else "Final!". So we implement that.

    Implementation: read n,a,b. Compute k = log2(n). Compute x = (a-1) xor (b-1). Compute round = floor(log2(x)) + 1. Since x is integer >0 (a != b ensures x >0). In C++ we can compute using bit operations: loop or use builtin __builtin_clz to find highest set bit. But n <=256 so simple loop fine.

    Alternatively, we can use while loop to check block conditions: r = 1; while ( ( (a-1) >> r ) != ( (b-1) >> r ) ) r++; round = r; This finds the smallest r such that shifting right r bits gives equality? Wait check: For r=1: shift right 1 => floor((a-1)/2). For equality we need floor((a-1)/2^r) == floor((b-1)/2^r). Actually the condition for meeting round is that floor((a-1)/2^r) are equal. But earlier we said meeting round is the smallest r where they are equal. But that condition gave meeting round directly? Let's test: a=1,b=2: (0>>1)=0, (1>>1)=0 => equality at r=1? But they meet in round1, not round2. Wait, careful: The equality condition using floor((a-1)/2^r) equal? For round1 (r=1), floor(0/2)=0, floor(1/2)=0 => equal at r=1. That would indicate meeting round = 1? But they meet in round1 indeed. So r=1 is meeting round. But earlier we thought that meeting round is smallest r such that ceil equality holds, which is same as floor equality for r? Let's verify with a=1,b=3: (0>>1)=0, (2>>1)=1 => not equal at r=1. At r=2: (0>>2)=0, (2>>2)=0 => equal at r=2. They meet in round2. So that matches. a=1,b=5: (0>>1)=0, (4>>1)=2 => not equal; (0>>2)=0, (4>>2)=1 => not equal; (0>>3)=0, (4>>3)=0 => equal at r=3, meet in final (round3). So indeed meeting round = smallest r such that ((a-1)>>r) == ((b-1)>>r). But careful: For r=0, shift by 0 gives original values, they are different (since a!=b). So r starts from 1. This condition yields the meeting round directly. Let's test a=2,b=3: (1>>1)=0, (2>>1)=1 => not equal; (1>>2)=0, (2>>2)=0 => equal at r=2, meeting round2. Good.

    But is there any case where they meet in round 1 and r=1 equality holds? Yes.

    So we can compute round as:

    int round = 1; while ( ((a-1)>>round) != ((b-1)>>round) ) { round++; } // round is the meeting round.

    We need to ensure round doesn't exceed log2(n). But since they will always become equal when round = log2(n) (since shifting by log2(n) yields 0 for all), it will stop at <= log2(n). So that's fine.

    Then if round == log2(n), output "Final!", else output round.

    But careful: log2(n) must be integer; n is power of two. In C++, we can compute total_rounds = 0; int tmp = n; while (tmp > 1) { tmp >>= 1; total_rounds++; } or use built-in. Or compute total_rounds = (int)log2(n). But might be floating inaccuracies; better to use bit scan or while loop.

    Simpler: we can compute total_rounds = 0; while ( (1 << total_rounds) < n ) total_rounds++; Actually n is exactly 2^k, so total_rounds = k.

    Alternatively, we can compute round via xor method as described, then compare round to total_rounds.

    Given constraints small, any method works.

    Edge case: n=2. Then total_rounds=1, only final. For any a,b distinct, they will meet in round1, which is the final. So output "Final!". Let's test: n=2, a=1,b=2. ((0)>>1)=0, ((1)>>1)=0 => round=1. total_rounds=1 => round==total_rounds => output "Final!". That matches: only final.

    Thus solution is straightforward.

    Implementation plan in Python (since it's a typical Codeforces problem) but we need to output as described.

    But note: The problem might be from Codeforces: "Football" or something. Usually they ask to output "Final!" if final. So we implement.

    Let's produce Python code:

    def solve(): import sys n, a, b = map(int, sys.stdin.readline().split()) # zero-index a -= 1 b -= 1 round = 1 while (a >> round) != (b >> round): round += 1 # compute total rounds total_rounds = 0 temp = n while temp > 1: temp //= 2 total_rounds += 1 if round == total_rounds: print("Final!") else: print(round)

    Testing with examples:

    Example1: n=4,total_rounds=2; a=0,b=1; round1: (0>>1)=0,(1>>1)=0 -> round=1 -> print 1. OK.

    Example2: n=8,total_rounds=3; a=1,b=5; round1: 0 vs 2? Actually (1>>1)=0,(5>>1)=2 not equal; round2: (1>>2)=0,(5>>2)=1 not equal; round3: (1>>3)=0,(5>>3)=0 equal => round=3 -> Final! OK.

    Example3: n=8,a=6,b=4? Actually a=7->6,b=5->4. round1: (6>>1)=3,(4>>1)=2 not equal; round2: (6>>2)=1,(4>>2)=1 equal => round=2 -> print 2.

    Thus correct.

    But be careful: In Python, shifting works fine.

    Alternatively, we can compute using xor: x = a ^ b; round = x.bit_length() # because bit_length returns number of bits needed, e.g., 1->1, 2->2, 4->3. But careful: For a ^ b, we want the position of highest set bit (0-indexed). bit_length gives number of bits, so highest set bit index = bit_length - 1. Then round = highest set bit index + 1 = (a^b).bit_length(). So round = ( (a-1) ^ (b-1) ).bit_length(). Let's test: a=1,b=2: (0^1)=1 -> bit_length=1 -> round=1. Good. a=1,b=3: 0^2=2 -> bit_length=2 -> round=2. a=1,b=5: 0^4=4 -> bit_length=3 -> round=3. So indeed round = ((a-1) ^ (b-1)).bit_length(). But careful: bit_length of 0 is 0, but a != b so XOR non-zero. So we can compute round = ((a-1)^(b-1)).bit_length(). Then total_rounds = n.bit_length() - 1 (since n is power of two). For n=8 (binary 1000), bit_length=4, total_rounds=3. So we can compute:

    round = ((a-1)^(b-1)).bit_length() total_rounds = n.bit_length() - 1 if round == total_rounds: print("Final!") else print(round)

    But verify for n=2: n=2 (binary 10) bit_length=2 => total_rounds=1; a=1,b=2 -> (0^1)=1 bit_length=1 => round=1 => Final!. Good.

    n=4: bit_length=3 => total_rounds=2; a=1,b=2 => round=1 => output 1; correct.

    n=4 a=1,b=3: (0^2)=2 bit_length=2 => round=2 => round==total_rounds? total_rounds=2 => Final! But is that correct? For n=4, teams 1 and 3: bracket: (1,2) and (3,4). They meet only if both win: 1 beats 2, 3 beats 4, then final round (round2) they meet. So indeed Final! So output should be "Final!". That matches. So using XOR bit_length works.

    But check n=4 a=2,b=4: (1^3)=2 bit_length=2 => round=2 => Final! Actually 2 and 4: round1: (1,2) vs (3,4). To meet: 2 beats 1, 4 beats 3; final round2. So final. Yes.

    Thus the XOR method is elegant.

    So we can implement either.

    Now write solution in Python.

    But note: Input constraints: n up to 256. So either method is fine.

    Thus final answer: compute round = bit_length(xor) and total_rounds = bit_length(n)-1. If round == total_rounds print "Final!" else print round.

    We'll implement as:

    import sys

    def main(): n, a, b = map(int, sys.stdin.readline().split()) a -= 1 b -= 1 xor = a ^ b round = xor.bit_length() # since xor > 0 total_rounds = n.bit_length() - 1 if round == total_rounds: print("Final!") else: print(round)

    if name == "main": main()

    Edge: if xor=0? a == b but input guarantees a and b not equal, so xor>0.

    Thus answer.

    Now I'll produce final response: The solution is to output round number or "Final!" based on bracket logic. I'll include explanation. ```python

    import sys

    def solve() -> None: n, a, b = map(int, sys.stdin.readline().split()) a -= 1 # zero‑based indices b -= 1 xor = a ^ b meeting_round = xor.bit_length() # because xor > 0 (a != b) total_rounds = n.bit_length() - 1 # n = 2^k ⇒ k = bit_length - 1

    if meeting_round == total_rounds:
        print("Final!")
    else:
        print(meeting_round)
    

    if name == "main": solve()