**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
def simulate_quidditch_game(N, M, field, T, actions):
    # Parse the initial field
    players = {}
    goals = {}
    quaffle = None
    bludger = None
    snitch = None

    for i in range(N):
        for j in range(M):
            cell = field[i][j]
            if cell in ['..', 'RG', 'BG']:
                if cell == 'RG':
                    goals[(i, j)] = 'RG'
                elif cell == 'BG':
                    goals[(i, j)] = 'BG'
            elif cell.endswith('Q'):
                quaffle = (i, j)
            elif cell == '.B':
                bludger = (i, j)
            elif cell == '.S':
                snitch = (i, j)
            else:  # Players
                players[cell] = {'pos': (i, j), 'has_quaffle': False}

    # Directions mapping
    directions = {'U': (-1, 0), 'D': (1, 0), 'L': (0, -1), 'R': (0, 1)}

    # Game events and scores
    events = []
    scores = {'RED': 0, 'BLUE': 0}

    # Process each action
    for t, action in enumerate(actions):
        entity, command = action[0], action[1]
        if command in directions:
            dx, dy = directions[command]
            if entity == '.Q':
                x, y = quaffle
                quaffle = (x + dx, y + dy)
            elif entity == '.B':
                x, y = bludger
                bludger = (x + dx, y + dy)
            elif entity == '.S':
                x, y = snitch
                snitch = (x + dx, y + dy)
            else:
                x, y = players[entity]['pos']
                new_pos = (x + dx, y + dy)
                players[entity]['pos'] = new_pos
                # Check for bludger collision
                if new_pos == bludger:
                    events.append(f"{t} {entity} ELIMINATED")
                    del players[entity]
                # Check for snitch catch
                if new_pos == snitch:
                    team = 'RED' if entity[0] == 'R' else 'BLUE'
                    events.append(f"{t} {team} CATCH GOLDEN SNITCH")
                    scores[team] += 10
                    break
        elif command == 'C':
            ball = action[2]
            if ball == '.Q':
                players[entity]['has_quaffle'] = True
        elif command == 'T':
            x, y = players[entity]['pos']
            if (x, y) in goals:
                goal_type = goals[(x, y)]
                if (entity[0] == 'R' and goal_type == 'BG') or (entity[0] == 'B' and goal_type == 'RG'):
                    team = 'RED' if entity[0] == 'R' else 'BLUE'
                else:
                    team = 'BLUE' if entity[0] == 'R' else 'RED'
                events.append(f"{t} {team} GOAL")
                scores[team] += 1
                # Reset quaffle to the middle
                quaffle = ((N-1)//2, (M-1)//2)
            players[entity]['has_quaffle'] = False

    # Print events
    for event in events:
        print(event)
    print(f"FINAL SCORE: {scores['RED']} {scores['BLUE']}")

# Example usage (not part of the submission)
N, M = 3, 5
field = [
    ['..', '..', 'R0', '..', '..'],
    ['RG', '..', '.Q', '..', 'BG'],
    ['..', '..', 'B0', '..', '..']
]
T = 12
actions = [
    ('R0', 'D'), ('R0', 'C', '.Q'), ('R0', 'R'), ('R0', 'T'), ('R0', 'D'),
    ('B0', 'R'), ('B0', 'U'), ('B0', 'C', '.Q'), ('B0', 'L'), ('B0', 'L'),
    ('B0', 'L'), ('B0', 'T')
]
simulate_quidditch_game(N, M, field, T, actions)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
4
R0 D
R0 C .Q
R0 L
R0 L
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
#include <bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define Un unsigned
#define l(p, i) tree[i][p].l
#define r(p, i) tree[i][p].r
#define lazy(p, i) tree[i][p].lazy
#define cnt(p, i) tree[i][p].cnt
#define ls (p << 1)
#define rs (p << 1 | 1)
#define YE cout<<"YES"<<endl
#define Ye cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define RET return 0
#define fi first
#define se second
#define FOR(i,x,y) for (int i = x; i <= y; i ++)
#define ROF(i,x,y) for (int i = x; i >= y; i --)

using namespace std;

const int seed = 13131, N = 1e2 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;

int read ()
{
    int f = 1, ret = 0;
    char c = getchar ();
    while (!isdigit (c))
    {
        if (c == '-') f = -1;
        c = getchar ();
    }
    while (isdigit (c))
    {
        ret = ret * 10 + (c - '0');
        c = getchar ();
    }
    return f * ret;
}

string s[N][N];
struct node
{
    int x, y;
};
map <string, node> mp;
int n, m, ans1, ans2;
bool vis1[N][N], vis2[N][N];

void xd (string x, int i)
{
    if (mp[".B"].x == mp[x].x && mp[".B"].y == mp[x].y)
    {
        cout << i << ' ' << x << " ELIMINATED";
        mp[x] = {0, 0};
    }
    return ;
}

signed main ()
{
    n = read (), m = read ();
    mp[".B"] = {n + 1, m + 1};
    FOR (i, 1, n)
    {
        FOR (j, 1, m)
        {
            cin >> s[i][j];
            mp[s[i][j]] = {i, j};
        }
    }
    int T = read ();
    FOR (i, 0, T - 1)
    {
        string id; char ID;
        cin >> id >> ID;
        if (ID == 'U')
        {
			if (mp[".Q"].x == mp[id].x && mp[".Q"].y == mp[id].y)
            {
				mp[".Q"].x --;
			}
			mp[id].x --;
		}
		if (ID == 'D')
        {
			if (mp[".Q"].x == mp[id].x && mp[".Q"].y == mp[id].y)
            {
				mp[".Q"].x ++;
			}
			mp[id].x ++;
		}
		if (ID == 'L')
        {
			if (mp[".Q"].x == mp[id].x && mp[".Q"].y == mp[id].y)
            {
				mp[".Q"].y --;
			}
			mp[id].y --;
		}
		if (ID == 'R')
        {
			if (mp[".Q"].x == mp[id].x && mp[".Q"].y == mp[id].y)
            {
				mp[".Q"].y ++;
			}
			mp[id].y ++;
		}
		if (ID == 'C')
        {
			string ss;
			cin >> ss;
			if (ss == ".S")
            {
				if (id[0] == 'R')
                {
					cout << i << " RED CATCH GOLDEN SNITCH \n";
					ans1 += 10;
				}
				if (id[0] == 'B')
                {
					cout << i << " BLUE CATCH GOLDEN SNITCH \n";
					ans2 += 10;
				}
				break;
			}
		}
		if (ID == 'T')
        {
			if (s[mp[id].x][mp[id].y] == "BG")
            {
				cout << i << " RED GOAL \n";
				ans1 ++;
				mp[".Q"] = {(n + 1) / 2, (m + 1) / 2};
			}
			if (s[mp[id].x][mp[id].y] == "RG")
            {
				cout << i << " BLUE GOAL \n";
				ans2 ++;
				mp[".Q"] = {(n + 1) / 2, (m + 1) / 2};
			}
		}
        xd ("B0", i); xd ("B1", i); xd ("B2", i); xd ("B3", i);
		xd ("B4", i); xd ("B5", i); xd ("B6", i); xd ("B7", i);
		xd ("B8", i); xd ("B9", i); xd ("R0", i); xd ("R1", i);
		xd ("R2", i); xd ("R3", i); xd ("R4", i); xd ("R5", i);
		xd ("R6", i); xd ("R7", i); xd ("R8", i); xd ("R9", i);
    }
    cout << "FINAL SCORE: " << ans1 << ' ' << ans2 << endl;
    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
6
R0 D
R0 C .Q
R0 L
R0 L
R0 T
B0 D
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
def parse_input():
    import sys
    input = sys.stdin.read
    data = input().splitlines()

    N, M = map(int, data[0].split())
    field = [line.split() for line in data[1:N+1]]
    T = int(data[N+1])
    actions = data[N+2:N+2+T]

    return N, M, field, T, actions

def find_entities(field):
    entities = {}
    for i, row in enumerate(field):
        for j, cell in enumerate(row):
            if cell != '..':
                entities[cell] = (i, j)
    return entities

def simulate_game(N, M, field, T, actions):
    entities = find_entities(field)
    scores = {'R': 0, 'B': 0}
    quaffle_carrier = None
    events = []

    for t, action in enumerate(actions):
        parts = action.split()
        entity = parts[0]
        action_type = parts[1]

        if action_type in 'UDLR':
            # Move the entity
            i, j = entities[entity]
            if action_type == 'U':
                i -= 1
            elif action_type == 'D':
                i += 1
            elif action_type == 'L':
                j -= 1
            elif action_type == 'R':
                j += 1
            entities[entity] = (i, j)

            # Check for elimination by Bludger
            if entity[0] in 'RB' and '.B' in entities and entities[entity] == entities['.B']:
                events.append((t, f"{entity} ELIMINATED"))
                del entities[entity]
                if quaffle_carrier == entity:
                    quaffle_carrier = None

        elif action_type == 'C':
            # Catch a ball
            ball = parts[2]
            if ball == '.Q':
                quaffle_carrier = entity
            elif ball == '.S':
                # Golden Snitch caught
                team = 'RED' if entity[0] == 'R' else 'BLUE'
                events.append((t, f"{team} CATCH GOLDEN SNITCH"))
                scores[entity[0]] += 10
                break

        elif action_type == 'T':
            # Throw the Quaffle
            if quaffle_carrier == entity:
                quaffle_carrier = None
                i, j = entities[entity]
                entities['.Q'] = (i, j)

                # Check for scoring
                if field[i][j] == 'RG' and entity[0] == 'B':
                    events.append((t, "BLUE GOAL"))
                    scores['B'] += 1
                    entities['.Q'] = ((N+1)//2 - 1, (M+1)//2 - 1)
                elif field[i][j] == 'BG' and entity[0] == 'R':
                    events.append((t, "RED GOAL"))
                    scores['R'] += 1
                    entities['.Q'] = ((N+1)//2 - 1, (M+1)//2 - 1)
                elif field[i][j] == 'RG' and entity[0] == 'R':
                    events.append((t, "BLUE GOAL"))
                    scores['B'] += 1
                    entities['.Q'] = ((N+1)//2 - 1, (M+1)//2 - 1)
                elif field[i][j] == 'BG' and entity[0] == 'B':
                    events.append((t, "RED GOAL"))
                    scores['R'] += 1
                    entities['.Q'] = ((N+1)//2 - 1, (M+1)//2 - 1)

    # Output events
    for event in events:
        print(event[0], event[1])

    # Output final score
    print(f"FINAL SCORE: {scores['R']} {scores['B']}")

def main():
    N, M, field, T, actions = parse_input()
    simulate_game(N, M, field, T, actions)

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
3 3
.. .. ..
RG .. BG
.. .. ..
4
R0 D
R0 C .Q
R0 D
R0 T
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
def parse_input():
    import sys
    input = sys.stdin.read
    data = input().splitlines()

    N, M = map(int, data[0].split())
    field = [line.split() for line in data[1:N+1]]
    T = int(data[N+1])
    actions = data[N+2:N+2+T]

    return N, M, field, T, actions

def find_entities(field):
    entities = {}
    for i, row in enumerate(field):
        for j, cell in enumerate(row):
            if cell != '..':
                entities[cell] = (i, j)
    return entities

def simulate_game(N, M, field, T, actions):
    entities = find_entities(field)
    scores = {'R': 0, 'B': 0}
    quaffle_carrier = None
    events = []

    for t, action in enumerate(actions):
        parts = action.split()
        entity = parts[0]
        command = parts[1]

        if command in 'UDLR':
            # Move entity
            x, y = entities[entity]
            if command == 'U':
                x -= 1
            elif command == 'D':
                x += 1
            elif command == 'L':
                y -= 1
            elif command == 'R':
                y += 1
            entities[entity] = (x, y)

            # Check for elimination
            if entity[0] in 'RB' and '.B' in entities and entities[entity] == entities['.B']:
                events.append(f"{t} {entity} ELIMINATED")
                del entities[entity]
                if quaffle_carrier == entity:
                    quaffle_carrier = None

        elif command == 'C':
            # Catch ball
            ball = parts[2]
            if ball == '.Q':
                quaffle_carrier = entity
            elif ball == '.S':
                team = 'RED' if entity[0] == 'R' else 'BLUE'
                events.append(f"{t} {team} CATCH GOLDEN SNITCH")
                scores[entity[0]] += 10
                break

        elif command == 'T':
            # Throw Quaffle
            if quaffle_carrier == entity:
                quaffle_carrier = None
                entities['.Q'] = entities[entity]

        # Check for scoring
        if '.Q' in entities:
            qx, qy = entities['.Q']
            if field[qx][qy] == 'RG':
                events.append(f"{t} BLUE GOAL")
                scores['B'] += 1
                entities['.Q'] = ((N+1)//2 - 1, (M+1)//2 - 1)
            elif field[qx][qy] == 'BG':
                events.append(f"{t} RED GOAL")
                scores['R'] += 1
                entities['.Q'] = ((N+1)//2 - 1, (M+1)//2 - 1)

    # Print events
    for event in events:
        print(event)

    # Print final score
    print(f"FINAL SCORE: {scores['R']} {scores['B']}")

def main():
    N, M, field, T, actions = parse_input()
    simulate_game(N, M, field, T, actions)

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes potential bugs in the given buggy code, we need to consider edge cases and scenarios that could cause the code to fail. Here are some key points to consider:

1. **Initial Setup**: Ensure the field is set up in a way that can trigger various events, such as scoring, elimination, and catching the Golden Snitch.
2. **Entity Movements**: Create actions that cause entities to move in ways that can lead to scoring, elimination, or catching the Golden Snitch.
3. **Edge Cases**: Include scenarios where the Quaffle is thrown and caught in a single step, or where a player is eliminated while carrying the Quaffle.

Let's create a small-scale test input that meets these criteria:

```plaintext
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. R1 .B B1 ..
8
R0 D
R0 C .Q
R0 R
R0 R
R0 T
B0 L
B0 L
B0 T
```

### Explanation:
1. **Field Setup**:
   - The field is a 5x5 grid.
   - There are two goals: one red (RG) and one blue (BG).
   - Red player R0 starts near the red goal and the Quaffle.
   - Blue player B0 starts near the blue goal.
   - Red player R1 and Blue player B1 are near the Bludger.

2. **Actions**:
   - R0 moves down and catches the Quaffle.
   - R0 moves right twice and throws the Quaffle.
   - B0 moves left twice and throws the Quaffle.

### Expected Output:
- R0 should score a goal in the blue goal (BLUE GOAL).
- B0 should score a goal in the red goal (RED GOAL).
- The final score should be 1-1.

This test input should help expose any issues in the buggy code, particularly with handling scoring and entity movements.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
from typing import List, Tuple, Dict

class Entity:                                                               # ok
    def __init__(self, team: str, id: str, x: int, y: int):
        self.team = team
        self.id = id
        self.x = x
        self.y = y
        self.carrying = None

    def move(self, direction: str):
        if direction == 'U':
            self.y -= 1
        elif direction == 'D':
            self.y += 1
        elif direction == 'L':
            self.x -= 1
        elif direction == 'R':
            self.x += 1

    def __repr__(self):
        return f"{self.id}({self.x},{self.y})"

class Game:
    def __init__(self, n: int, m: int, field: List[List[str]]):
        self.n = n
        self.m = m
        self.field = field
        self.entities: Dict[str, Entity] = {}
        self.goals: Dict[str, List[Tuple[int, int]]] = {'R': [], 'B': []}
        self.score = {'R': 0, 'B': 0}
        self.events = []
        self.time = 0
        self.game_over = False

        self.parse_field()

    def parse_field(self):
        for y in range(self.n):
            for x in range(self.m):
                cell = self.field[y][x]
                if cell[0] in 'RB' and cell[1] in '0123456789':
                    self.entities[cell] = Entity(cell[0], cell, x, y)
                elif cell == 'RG':
                    self.goals['R'].append((x, y))
                elif cell == 'BG':
                    self.goals['B'].append((x, y))
                elif cell == '.Q':
                    self.entities['.Q'] = Entity('', '.Q', x, y)
                elif cell == '.B':
                    self.entities['.B'] = Entity('', '.B', x, y)
                elif cell == '.S':
                    self.entities['.S'] = Entity('', '.S', x, y)

    def perform_action(self, entity_id: str, action: str, extra: str = None):
        if entity_id not in self.entities:
            return  # Skip action if entity no longer exists

        entity = self.entities[entity_id]

        # print(f"Action: {entity_id} {action} {extra if extra else ''}")
        # print(f"Before action: {entity}, carrying: {entity.carrying}")

        if action in 'UDLR':
            entity.move(action)
            if entity.carrying:
                entity.carrying.x = entity.x
                entity.carrying.y = entity.y
            self.check_collisions(entity)
        elif action == 'C':
            # print('aaaaaa')
            if extra in self.entities:
                caught_entity = self.entities[extra]
                # print('bbbbbb')
                entity.carrying = caught_entity
                # Update the position of the caught entity immediately upon catching
                caught_entity.x, caught_entity.y = entity.x, entity.y
        elif action == 'T':
            if entity.carrying:
                thrown_entity = entity.carrying
                entity.carrying = None
                self.check_scoring(entity, thrown_entity)

        # print(f"After action: {entity}, carrying: {entity.carrying}")
        # print(f"Quaffle position: {self.entities['.Q']}")

        self.time += 1

    def check_collisions(self, entity: Entity):
        if entity.id == 'B':
            players_to_remove = []
            for player_id, player in self.entities.items():
                if player_id[0] in 'RB' and player.x == entity.x and player.y == entity.y:
                    self.events.append(f"{self.time} {player_id} ELIMINATED")
                    if player.carrying:
                        player.carrying = None
                    players_to_remove.append(player_id)

            for player_id in players_to_remove:
                del self.entities[player_id]

    def check_scoring(self, entity: Entity, thrown_entity: Entity):
        if thrown_entity.id == '.Q':
            if (entity.x, entity.y) in self.goals['R']:
                self.score['B'] += 1
                self.events.append(f"{self.time} BLUE GOAL")
                self.reset_quaffle()
            elif (entity.x, entity.y) in self.goals['B']:
                self.score['R'] += 1
                self.events.append(f"{self.time} RED GOAL")
                self.reset_quaffle()

    def reset_quaffle(self):
        quaffle = self.entities['.Q']
        quaffle.x = (self.m + 1) // 2 - 1
        quaffle.y = (self.n + 1) // 2 - 1
        for entity in self.entities.values():
            if entity.carrying and entity.carrying.id == 'Q':
                entity.carrying = None

    def print_field(self):
        print(f"\nTime: {self.time}")
        print(f"Score: Red {self.score['R']} - Blue {self.score['B']}")
        field = [['..'] * self.m for _ in range(self.n)]

        for goal_type, positions in self.goals.items():
            for x, y in positions:
                field[y][x] = f"{goal_type}G"

        for entity in self.entities.values():
            cell = field[entity.y][entity.x]
            if cell == '..':
                field[entity.y][entity.x] = entity.id
            else:
                field[entity.y][entity.x] += entity.id
            if entity.carrying:
                field[entity.y][entity.x] += f"({entity.carrying.id})"

        for row in field:
            print(' '.join(f"{cell:>6}" for cell in row))
        print()

def main():
    n, m = map(int, input().split())
    field = [input().split() for _ in range(n)]
    game = Game(n, m, field)

    # game.print_field()  # Print initial state

    t = int(input())
    for _ in range(t):
        action = input().split()
        entity_id = action[0]
        action_type = action[1]
        extra = action[2] if len(action) > 2 else None
        game.perform_action(entity_id, action_type, extra)
        # game.print_field()  # Print state after each action
        if game.game_over:
            break

    game.events.sort(key=lambda x: (int(x.split()[0]), x.split()[1]))
    # print("\nEvents:")
    for event in game.events:
        print(event)
    print(f"FINAL SCORE: {game.score['R']} {game.score['B']}")

if __name__ == "__main__":
    main()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes potential bugs in the provided code, let's consider the following scenarios:

1. **Player Elimination by Bludger**: Ensure that a player can be eliminated by a Bludger, and the game logic correctly handles the elimination.
2. **Scoring in the Wrong Goal**: Ensure that a player can score in the wrong goal, and the correct team gets the point.
3. **Golden Snitch Capture**: Ensure that capturing the Golden Snitch ends the game and awards 10 points to the capturing team.
4. **Quaffle Reset**: Ensure that the Quaffle is correctly reset to the middle of the field after a goal is scored.
5. **Multiple Entities in the Same Cell**: Ensure that the game can handle multiple entities (players, balls) in the same cell without causing issues.

Let's construct a test input that includes these scenarios:

```plaintext
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. R1 .B B1 ..
10
.B L
.B U
.B U
B0 L
B0 L
B0 C .Q
B0 L
B0 L
B0 L
B0 T
```

### Explanation of the Test Input:
1. **Initial Setup**:
   - The field is a 5x5 grid.
   - Red goal (RG) at (2, 2) and Blue goal (BG) at (2, 4).
   - Red player R0 and Blue player B0 are near the Quaffle (Q) at (2, 3).
   - Red player R1 and Blue player B1 are near the Bludger (B) at (4, 2).

2. **Actions**:
   - The Bludger (B) moves left, up, and up, reaching the position (2, 1).
   - Blue player B0 moves left, left, and catches the Quaffle (Q).
   - Blue player B0 moves left, left, left, and throws the Quaffle (Q) into the Red goal (RG).

### Expected Output:
1. **Player Elimination**:
   - At time 2, R0 is eliminated by the Bludger.
   - At time 4, B0 is eliminated by the Bludger.

2. **Scoring in the Wrong Goal**:
   - At time 9, B0 scores in the Red goal, and the Red team gets a point.

3. **Final Score**:
   - The final score should be 1 (Red) to 0 (Blue).

```plaintext
2 R0 ELIMINATED
4 B0 ELIMINATED
9 RED GOAL
FINAL SCORE: 1 0
```

This test input is designed to cover several edge cases and ensure that the game logic handles player eliminations, scoring in the wrong goal, and multiple entities in the same cell correctly.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <stack>
#define ll long long
using namespace std;

const int mod = 998244353;

void solve(){
    int n, m;
    cin >> n >> m;
    pair<pair<int,int>,pair<string, int>> players [20];//x, y, state
    for(int i = 0; i < 20; i++){
        players[i] = make_pair(make_pair(-1, -1), make_pair("", 0));
    }
    //1 = carrying
    //0 = nothing
    //-1 = dead (we don't want the bludger to kill the same player repeatedly)
    bool redGoal [n][m];
    bool blueGoal [n][m];
    pair<int,int> quaffle;
    pair<int,int> bludger;
    pair<int,int> snitch;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            redGoal[i][j] = false;
            blueGoal[i][j] = false;
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char c1;
            char c2;
            cin >> c1 >> c2;
            if(c1 == 'R'){
                if('0' <= c2 && c2 <= '9'){
                    string s = "R";
                    s = s + c2;
                    players[c2 - '0' + 10] = make_pair(make_pair(i, j), make_pair(s, 0));
                }
                if(c2 == 'G'){
                    redGoal[i][j] = true;
                }
            }else if(c1 == 'B'){
                if('0' <= c2 && c2 <= '9'){
                    string s = "B";
                    s = s + c2;
                    players[c2 - '0'] = make_pair(make_pair(i, j), make_pair(s, 0));
                }
                if(c2 == 'G'){
                    blueGoal[i][j] = true;
                }
            }else{
                if(c2 == 'Q'){
                    quaffle = make_pair(i, j);
                }else if(c2 == 'B'){
                    bludger = make_pair(i, j);
                }else if(c2 == 'S'){
                    snitch = make_pair(i, j);
                }
            }
        }
    }
    int redScore = 0;
    int blueScore = 0;
    int t;
    cin >> t;
    for(int i = 0; i < t; i++){
        char c1, c2;
        cin >> c1 >> c2;
        if(c1 == '.'){
            if(c2 == 'Q'){
                char c3;
                cin >> c3;
                if(c3 == 'U'){
                    quaffle.first--;
                }else if(c3 == 'D'){
                    quaffle.first++;
                }else if(c3 == 'L'){
                    quaffle.second--;
                }else{
                    quaffle.second++;
                }
            }else if(c2 == 'B'){
                char c3;
                cin >> c3;
                if(c3 == 'U'){
                    bludger.first--;
                }else if(c3 == 'D'){
                    bludger.first++;
                }else if(c3 == 'L'){
                    bludger.second--;
                }else{
                    bludger.second++;
                }
                for(int j = 0; j < 20; j++){
                    if(bludger == players[j].first && players[j].second.second != -1){
                        cout << i << " " << players[j].second.first << " " << "ELIMINATED" << endl;
                        players[j].second.second = -1;
                    }
                }
            }else if(c2 == 'S'){
                char c3;
                cin >> c3;
                if(c3 == 'U'){
                    snitch.first--;
                }else if(c3 == 'D'){
                    snitch.first++;
                }else if(c3 == 'L'){
                    snitch.second--;
                }else{
                    snitch.second++;
                }
            }
        }else{
            if(c2 == 'G'){
                //goals surley can't move trust
            }else{
                //player
                int pid = (c2 - '0');
                if(c1 == 'R'){
                    pid += 10;
                }
                char c3;
                cin >> c3;
                if(c3 == 'U' || c3 == 'D' || c3 == 'L' || c3 == 'R'){
                   // cout << "!" << players[pid].second.second << endl;
                    if(c3 == 'U'){
                        players[pid].first.first--;
                    }else if(c3 == 'D'){
                        players[pid].first.first++;
                    }else if(c3 == 'L'){
                        players[pid].first.second--;
                    }else{
                        players[pid].first.second++;
                    }
                    if(players[pid].second.second == 1){
                        quaffle = players[pid].first;
                    }
                    if(players[pid].first == bludger){
                        //cout << "!" << pid << endl;
                        cout << i << " " << players[pid].second.first << " " << "ELIMINATED" << endl;
                        players[pid].second.second = -1;
                    }
                }else if(c3 == 'C'){
                    char tp;
                    cin >> tp;
                    cin >> tp;
                    players[pid].second.second = 1;
                    if(tp == 'S'){
                        if(pid < 10){
                            blueScore += 10;
                            cout << i << " BLUE CATCH GOLDEN SNITCH" << endl;
                            break;
                        }else{
                            redScore += 10;
                            cout << i << " RED CATCH GOLDEN SNITCH" << endl;
                            break;
                        }
                    }
                }else if(c3 == 'T'){
                    players[pid].second.second = 0;
                    if(redGoal[players[pid].first.first][players[pid].first.second]){
                        blueScore += 1;
                        cout << i << " BLUE GOAL" << endl;
                        quaffle = make_pair(n/2, m/2);
                    }
                    if(blueGoal[players[pid].first.first][players[pid].first.second]){
                        redScore += 1;
                        cout << i << " RED GOAL" << endl;
                        quaffle = make_pair(n/2, m/2);
                    }
                }
            }
        }
    }
    cout << "FINAL SCORE: " << redScore << " " << blueScore << endl;

}

int main(){
    int t = 1;
    for(int tc = 0; tc < t; tc++){
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to focus on edge cases and scenarios that can cause the code to fail. Here are some key points to consider:

1. **Bludger Elimination**: The bludger can eliminate multiple players in a single step, and the code should handle this correctly.
2. **Golden Snitch**: Catching the Golden Snitch should immediately end the game and award 10 points to the team.
3. **Scoring in the Wrong Goal**: Players scoring in their own goal should result in the opposing team scoring a point.
4. **Movement and Actions**: Ensure that players can move, catch, and throw the Quaffle correctly, and the Quaffle should return to the center of the field after a goal.

Given these points, let's create a small-scale test input that covers these scenarios:

```plaintext
5 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
.. .. .B .. ..
.. .. .S .. ..
10
R0 D
R0 C .Q
R0 D
R0 D
R0 T
B0 D
B0 C .Q
B0 U
B0 U
B0 T
```

### Explanation:

1. **Initial Setup**:
   - The field is a 5x5 grid.
   - Red team has a player (R0) and a goal (RG) at the top.
   - Blue team has a player (B0) and a goal (BG) at the bottom.
   - The Quaffle (.Q) is initially in the middle.
   - A Bludger (.B) and a Golden Snitch (.S) are present.

2. **Steps**:
   - **Step 0**: R0 moves down.
   - **Step 1**: R0 catches the Quaffle.
   - **Step 2**: R0 moves down.
   - **Step 3**: R0 moves down.
   - **Step 4**: R0 throws the Quaffle, which should score a point for the blue team (since it's in the red goal).
   - **Step 5**: B0 moves down.
   - **Step 6**: B0 catches the Quaffle.
   - **Step 7**: B0 moves up.
   - **Step 8**: B0 moves up.
   - **Step 9**: B0 throws the Quaffle, which should score a point for the red team (since it's in the blue goal).

### Expected Output:
```plaintext
4 BLUE GOAL
9 RED GOAL
FINAL SCORE: 1 1
```

This test input ensures that the code handles scoring in the wrong goal correctly and that the Quaffle returns to the center after each goal. It also tests the movement and actions of players, ensuring that the code can handle these scenarios without errors.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Playing Quidditch (Hard)
time_limit_ms: 1000
memory_limit_mb: 256
Description: This afternoon, you decided to enjoy the first days of Spring by taking a walk outside. As you come near the Quidditch field, you hear screams. Once again, there is a conflict about the score: the two teams are convinced that they won the game! To prevent this problem from happening one more time, you decide to get involved in the refereeing of the matches.

Now, you will stay in the stadium to watch the game and count the score. At the end of the game, you will decide the winner.

Today, two teams are competing: the red Gryffindor (R) and the blue Ravenclaw (B) team. Each team is composed of $$$P$$$ players ($$$1 \leq P \leq 10$$$).

The field is a rectangle of $$$N$$$ lines and $$$M$$$ columns ($$$3 \leq N, M \leq 99$$$, $$$N$$$ and $$$M$$$ are odd). All the positions are integers, and several entities are allowed to be at the same position in the field. At the beginning of the game, the field contains goals for the two teams (each team can own between one and five goals), the players, and exactly one Quaffle. In this version of the problem, one Bludger and a Golden Snitch can be present.

A game is composed of $$$T$$$ steps ($$$0 \leq T \leq 10000$$$). At each step, one entity on the field (a player or a ball) performs one action. All entities can move. A player can also catch a ball or throw the Quaffle that it is carrying. To catch a ball, a player must be located on the same cell as it. The Quaffle does not perform any action while it is being carried; it only follows the movements of the player. If a player carrying the Quaffle decides to throw it, the Quaffle is simply put at the current position of the player. If a player is on the same cell as a Bludger (either after a movement from the player or the Bludger), the player is eliminated. If the player is eliminated while it is carrying the Quaffle, the Quaffle remains on the cell containing both the player and the Bludger after the move. It is guaranteed that this never occurs while the player is in a cell containing a goal.

To win a point, a player must leave the Quaffle at a goal of the other team. When it does, the team of the player wins one point, and the Quaffle instantly moves to the middle of the field (the cell at the $$$(M+1)/2$$$-th column of the $$$(N+1)/2$$$-th line of the field, starting from 1). There is no goal in the middle of the field. If a player puts the ball in its own goal, the other team wins the point. If a player catches the Golden Snitch, their team wins 10 points and the game is over.

Input: On the first line, the integers $$$N$$$ and $$$M$$$.

The description of the field follows: $$$N$$$ lines of $$$M$$$ pairs of characters separated by spaces. Each pair of characters represents a position on the field. It can be either:

- .. to represent an empty cell
- R0, ..., R9, B0, ..., B9 to represent a player. The first character is the team of the player, and the second is the number of the player in the team. Each pair of characters is unique, but it is not guaranteed that all the pairs appear in the grid.
- RG or BG to represent a goal. The blue team tries to put the ball in a red goal (RG) while the red team tries to put the ball in a blue goal (BG).
- .Q to represent the Quaffle, which is the ball that the players use to score goals.
- .B to represent the Bludger.
- .S to represent the Golden Snitch.

The next line contains $$$T$$$, the number of steps that compose the game. $$$T$$$ lines follow, each describing one action. It contains several pieces of information separated by a space. First, a pair of characters representing the entity that must perform the action. Second, the description of the action:

- U, D, L, R indicate that the entity moves on the grid. It can move to the top of the grid (U), to the bottom (D), to the left (L), or to the right (R). Each entity moves by only one cell at a time.
- C indicates that the player catches the ball (only a player can catch a ball). Then, there is a space followed by a pair of characters: the description of the ball caught by the player. This information is needed since several balls can be in the same cell.
- T indicates that the player throws the Quaffle that it is carrying.

All the actions performed by the entities are guaranteed to be valid: the players stay in the field, don't catch a ball if they are not in the same cell, don't release the Quaffle if they are not carrying it, ...

Output: You must output the description of the main events of the game, one event per line. More precisely:

- Each time a team scores, you must print t RED GOAL or t BLUE GOAL, depending on the team who scored, where t is the current time (the position of the action in the list of actions, starting from 0). In the case where a player scores in the wrong goal (a red player scores in the red goal, or a blue player scores in the blue goal), you must print the name of the team who wins one point, that is, the other team.
- Each time a player is eliminated, you must print t p ELIMINATED, where t is the current time and p is the player who is eliminated. The format to print the player is the same as in the input.
- If the Golden Snitch is caught, you must print t RED CATCH GOLDEN SNITCH or t BLUE CATCH GOLDEN SNITCH, depending on the team who caught the Golden Snitch, where t is the current time.

The events must be printed in ascending order of t. If several players are eliminated at the same time, the events must be written is alphabetical order: B0, ..., B9, R0, ... R9.

At the end of the game, you must print the final score as: FINAL SCORE: r b, where r is the score of the red team and b is the score of the blue team.

Examples:
input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
12
R0 D
R0 C .Q
R0 R
R0 T
R0 D
B0 R
B0 U
B0 C .Q
B0 L
B0 L
B0 L
B0 T
output:
11 BLUE GOAL
FINAL SCORE: 0 1

input:
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
5
R0 D
R0 C .Q
R0 L
R0 L
R0 T
output:
4 BLUE GOAL
FINAL SCORE: 0 1

input:
5 5
.. .. .. .. ..
.. .. .. .. ..
RG R0 .Q B0 BG
.. .. .. .. ..
.. .. .B .. ..
5
.B L
.B U
.B U
B0 L
B0 L
output:
2 R0 ELIMINATED
4 B0 ELIMINATED
FINAL SCORE: 0 0

input:
5 5
.. R0 .S B0 ..
.. .. .. .. ..
RG .. .Q .. BG
.. .. .. .. ..
.. R1 .B B1 ..
4
.S D
R0 D
R0 R
R0 C .S
output:
3 RED CATCH GOLDEN SNITCH
FINAL SCORE: 10 0

Note: In the first example, the red player takes the Quaffle, move it and throw it. The blue player catches the ball, goes to the red goal and scores.

In the second example, the red player takes the ball and scores in the goal of their own team: the blue team wins a point.

In the third example, the Bludger goes at the position of R0: R0 is eliminated. Then, B0 moves to the position of the Bludger: B0 is eliminated too.

In the fourth example, a red player catches the Golden Snitch. Their team wins 10 points, and the game ends.

You can find one more example in the easy version of the problem

Buggy Code:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

const int N = 101, M = 101;
int n = 0, m = 0;
int red_goal = 0, blue_goal = 0;
string grid[N][M];

struct position {
	int x, y;
	bool operator == (const position& p) const {
		return x == p.x && y == p.y;
	}
};

struct Output {
	int t_;
	string message_;

	Output(int t, string message) {
		t_ = t;
		message_ = message;
	}

	bool operator < (const Output& o) const {
		if (t_ == o.t_) {
			return message_ < o.message_;
		}
		return t_ < o.t_;
	}
};
vector<Output>ans;

struct Quaffle {
	position po_;
	void init(int n, int m) {
		po_.x = (n-1)/2;
		po_.y = (m-1)/2;
	}
};
Quaffle quaffle;

struct S {
	position po_;
	void init(int x, int y) {
		po_.x = x;
		po_.y = y;
	}
	void Move(int t, const string& dir) {
		if (dir == "U") {
			po_.x--;
		}
		if (dir == "D") {
			po_.x++;
		}
		if (dir == "L") {
			po_.y--;
		}
		if (dir == "R") {
			po_.y++;
		}
	}
};
S s;

struct Player {
	string name_;
	string color_;
	int index_;
	position po_;
	bool has_ball_;
	bool eliminated_;

	Player() {
		index_ = -1;
		po_.x = -1;
		po_.y = -1;
		eliminated_ = false;
	}
	Player(const Player& p) {
		name_ = p.name_;
		color_ = p.color_;
		index_ = p.index_;
		po_ = p.po_;
		has_ball_ = p.has_ball_;
	}
	Player(int x, int y, string name) {
		po_.x = x;
		po_.y = y;
		name_ = name;
		color_ = name[0] == 'B' ? "BLUE" : "RED";
		index_ = name[1] - '0';
		eliminated_ = false;
	}

	void action(int t) {
		if (eliminated_) return;
		if (has_ball_ && grid[po_.x][po_.y][1] == 'G') {
			if (grid[po_.x][po_.y][0] == 'B') {
				red_goal++;
				ans.push_back(Output(t, "RED GOAL"));
			} else {
				blue_goal++;
				ans.push_back(Output(t, "BLUE GOAL"));
			}
			quaffle.init(n,m);
			has_ball_ = false;
			return;
		}
	}

	void Move(int t, const string& dir) {
		//cout << "time " << t << po_.x << " " << po_.y << " " << has_ball_ << endl;
		if (eliminated_) return;
		if (dir == "U") {
			po_.x--;
		}
		if (dir == "D") {
			po_.x++;
		}
		if (dir == "L") {
			po_.y--;
		}
		if (dir == "R") {
			po_.y++;
		}
		if (has_ball_) {
			quaffle.po_.x = po_.x;
			quaffle.po_.y = po_.y;
		}
	}

	void CatchBall(int t, const string& ball) {
		if (eliminated_) return;
		if (ball == ".S") {
			if (color_ == "RED") {
				ans.push_back(Output(t, color_ + " CATCH GOLDEN SNITCH"));
				red_goal += 10;
			} else {
				ans.push_back(Output(t, color_ + " CATCH GOLDEN SNITCH"));
				blue_goal += 10;
			}
		}
		has_ball_ = true;
	}

	void ThrowBall(int t) {
		if (eliminated_) return;
		action(t);
		has_ball_ = false;
	}

	void Eliminate(int t) {
		if (eliminated_) return;
		ans.push_back(Output(t, name_ + " ELIMINATED"));
		eliminated_ = true;
	}

};

struct B {
	position po_;
	void init(int x, int y) {
		po_.x = x;
		po_.y = y;
	}
	void Move(int t, const string& dir, map<string, Player>& blue, map<string, Player>& red) {
		//cout << "time " << t << po_.x << " " << po_.y << " " << dir << endl;
		if (dir == "U") {
			po_.x--;
		}
		if (dir == "D") {
			po_.x++;
		}
		if (dir == "L") {
			po_.y--;
		}
		if (dir == "R") {
			po_.y++;
		}
		for(auto itr = blue.begin(); itr != blue.end(); ++itr) {
			if (itr->second.po_ == po_) {
				itr->second.Eliminate(t);
			}
		}
		for(auto itr = red.begin(); itr != red.end(); ++itr) {
			if (itr->second.po_ == po_) {
				itr->second.Eliminate(t);
			}
		}
	}
};

map<string, Player>blue;
map<string, Player>red;
int blueN = 0, redN = 0;
B b;

int main() {
	cin >> n >> m;
	quaffle.init(n,m);
	for(int i = 0; i < n; ++i) {
		for(int j =  0; j < m; ++j) {
			cin >> grid[i][j];
			if (grid[i][j] == "..") {
				continue;
			}
			if (grid[i][j][1] == 'G') {
				continue;
			}
			if (grid[i][j] == ".Q") {
				continue;
			}
			if (grid[i][j] == ".B") {
				b.init(i, j);
				continue;
			}
			if (grid[i][j] == ".S") {
				s.init(i, j);
				continue;
			}
			if (grid[i][j][0] == 'B') {
				blue[grid[i][j]] = Player(i, j, grid[i][j]);
			}
			if (grid[i][j][0] == 'R') {
				red[grid[i][j]] = Player(i, j, grid[i][j]);
			}

		}
	}

	int T;
	cin >> T;
	for(int i = 0; i < T; ++i) {
		string role, command;
		cin >> role >> command;
		//cout << "get" << role << " " << command << endl;
		if (command == "C") {
			string ball;
			cin >> ball;
			if (role[0] == 'B') {
				blue[role].CatchBall(i, ball);
			} else if (role[0] == 'R') {
				red[role].CatchBall(i, ball);
			}
			continue;
		} else if (command == "T") {
			if (role[0] == 'B') {
				blue[role].ThrowBall(i);
			} else if (role[0] == 'R') {
				red[role].ThrowBall(i);
			}
			continue;
		}
		if (role[0] == 'B') {
			blue[role].Move(i, command);
			if (blue[role].po_ == b.po_) {
				blue[role].Eliminate(i);
			}
		} else if (role[0] == 'R') {
			red[role].Move(i, command);
			if (red[role].po_ == b.po_) {
				red[role].Eliminate(i);
			}
		} else if (role == ".B") {
			b.Move(i, command, blue, red);
		}
	}

	sort(ans.begin(), ans.end());
	for(int i = 0; i < ans.size(); ++i) {
		cout << ans[i].t_ << " " << ans[i].message_ << endl;;
	}
	cout << "FINAL SCORE: " << red_goal << " " << blue_goal << endl;
	return 0;

}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To create a challenging test input that exposes bugs in the provided code, we need to focus on edge cases and scenarios that are likely to cause issues. Here are the key areas to consider:

1. **Bludger Elimination**: Ensure that players are correctly eliminated when they encounter the Bludger.
2. **Goal Scoring**: Verify that scoring in the correct and incorrect goals is handled properly.
3. **Golden Snitch**: Test the scenario where the Golden Snitch is caught, which should end the game and award 10 points.
4. **Movement and Actions**: Ensure that players and the Bludger move correctly and that actions like catching and throwing the Quaffle are handled as expected.

Given the constraints and the need for a small-scale test input, let's create a scenario that covers these aspects:

- A 3x5 field with one goal for each team.
- One player from each team.
- One Bludger.
- One Golden Snitch.
- A sequence of actions that includes movement, catching the Quaffle, scoring, and catching the Golden Snitch.

Here is the test input:

```plaintext
3 5
.. .. R0 .. ..
RG .. .Q .. BG
.. .. B0 .. ..
6
R0 D
R0 C .Q
R0 R
R0 T
.B U
.S D
```

### Explanation:
1. **Initial Setup**:
   - The field is a 3x5 grid.
   - Red goal (RG) is at (1, 2).
   - Blue goal (BG) is at (1, 4).
   - Red player (R0) is at (0, 2).
   - Blue player (B0) is at (2, 2).
   - Quaffle (.Q) is at (1, 3).
   - Bludger (.B) is at (2, 2).
   - Golden Snitch (.S) is at (0, 2).

2. **Actions**:
   - **R0 D**: Red player moves down to (1, 2).
   - **R0 C .Q**: Red player catches the Quaffle.
   - **R0 R**: Red player moves right to (1, 3).
   - **R0 T**: Red player throws the Quaffle, which stays at (1, 3).
   - **.B U**: Bludger moves up to (1, 2), where it eliminates R0.
   - **.S D**: Golden Snitch moves down to (1, 2).

### Expected Output:
- **3 R0 ELIMINATED**: R0 is eliminated by the Bludger at time 3.
- **5 BLUE CATCH GOLDEN SNITCH**: B0 catches the Golden Snitch at time 5, awarding 10 points to the Blue team.
- **FINAL SCORE: 0 10**: The Blue team wins with 10 points.

This test input should help expose any issues in the handling of player elimination, goal scoring, and the Golden Snitch.