# 比赛记录 - Codeforces Round #831 (Div. 1 + Div. 2)

进度: 5 / 9

## A - Factorise N+M

Pak Chanek has a prime number\(^\dagger\) \(n\). Find a prime number \(m\) such that \(n + m\) is not prime.

\(^\dagger\) A prime number is a number with **exactly** \(2\) factors. The first few prime numbers are \(2,3,5,7,11,13,\ldots\). In particular, \(1\) is **not** a prime number.

### Input

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \leq t \leq 10^4\)) — the number of test cases. The following lines contain the description of each test case.

The only line of each test case contains a prime number \(n\) (\(2 \leq n \leq 10^5\)).

### Output

For each test case, output a line containing a prime number \(m\) (\(2 \leq m \leq 10^5\)) such that \(n + m\) is not prime. It can be proven that under the constraints of the problem, such \(m\) always exists.

If there are multiple solutions, you can output any of them.

### Example

#### input

1 | 3 |

#### output

1 | 2 |

### Note

In the first test case, \(m = 2\), which is prime, and \(n + m = 7 + 2 = 9\), which is not prime.

In the second test case, \(m = 7\), which is prime, and \(n + m = 2 + 7 = 9\), which is not prime.

In the third test case, \(m = 47837\), which is prime, and \(n + m = 75619 + 47837 = 123456\), which is not prime.

### 代码参考

## Show code

1 | /* |

## B - Jumbo Extra Cheese 2

Pak Chanek has \(n\) two-dimensional slices of cheese. The \(i\)-th slice of cheese can be represented as a rectangle of dimensions \(a_i \times b_i\). We want to arrange them on the two-dimensional plane such that:

- Each edge of each cheese is parallel to either the x-axis or the y-axis.
- The bottom edge of each cheese is a segment of the x-axis.
- No two slices of cheese overlap, but their sides can touch.
- They form one connected shape.

Note that we can arrange them in any order (the leftmost slice of cheese is not necessarily the first slice of cheese). Also note that we can rotate each slice of cheese in any way as long as all conditions still hold.

Find the minimum possible perimeter of the constructed shape.

### Input

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \leq t \leq 2 \cdot 10^4\)) — the number of test cases. The following lines contain the description of each test case.

The first line of each test case contains an integer \(n\) (\(1 \leq n \leq 2 \cdot 10^5\)) — the number of slices of cheese Pak Chanek has.

The \(i\)-th of the next \(n\) lines of each test case contains two integers \(a_i\) and \(b_i\) (\(1 \leq a_i,b_i \leq 10^9\)) — the dimensions of the \(i\)-th slice of cheese.

It is guaranteed that the sum of \(n\) over all test cases does not exceed \(2 \cdot 10^5\).

### Output

For each test case, output a line containing an integer representing the minimum possible perimeter of the constructed shape.

### Example

#### input

1 | 3 |

#### output

1 | 26 |

### Note

In the first test case, a way of getting the minimum possible perimeter is to arrange the slices of cheese as follows.

We can calculate that the perimeter of the constructed shape is \(2+5+1+1+1+1+3+1+5+1+2+3=26\). It can be shown that we cannot get a smaller perimeter.

Consider the following **invalid** arrangement.

Even though the perimeter of the shape above is \(24\), it does not satisfy all conditions of the problem. The bottom edge of the \(1 \times 1\) slice of cheese is not a segment of the x-axis.

In the second test case, a way of getting the minimum possible perimeter is to arrange the slices of cheese as follows.

We can calculate that the perimeter of the constructed shape is \(2+2+2+3+2+3+2+2+2+4=24\). It can be shown that we cannot get a smaller perimeter.

### 代码参考

## Show code

1 | /* |

## C - Bricks and Bags

There are \(n\) bricks numbered from \(1\) to \(n\). Brick \(i\) has a weight of \(a_i\).

Pak Chanek has \(3\) bags numbered from \(1\) to \(3\) that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick.

After Pak Chanek distributes the bricks, Bu Dengklek will take exactly one brick from each bag. Let \(w_j\) be the weight of the brick Bu Dengklek takes from bag \(j\). The score is calculated as \(|w_1 - w_2| + |w_2 - w_3|\), where \(|x|\) denotes the absolute value of \(x\).

It is known that Bu Dengklek will take the bricks in such a way that minimises the score. What is the maximum possible final score if Pak Chanek distributes the bricks optimally?

### Input

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \leq t \leq 2 \cdot 10^4\)) — the number of test cases. The following lines contain the description of each test case.

The first line of each test case contains an integer \(n\) (\(3 \leq n \leq 2 \cdot 10^5\)) — the number of bricks.

The second line of each test case contains \(n\) integers \(a_1, a_2, \ldots, a_n\) (\(1 \leq a_i \leq 10^9\)) — the weights of the bricks.

It is guaranteed that the sum of \(n\) over all test cases does not exceed \(2 \cdot 10^5\).

### Output

For each test case, output a line containing an integer representing the maximum possible final score if Pak Chanek distributes the bricks optimally.

### Example

#### input

1 | 3 |

#### output

1 | 6 |

### Note

In the first test case, one way of achieving a final score of \(6\) is to do the following:

- Put bricks \(1\), \(4\), and \(5\) into bag \(1\).
- Put brick \(3\) into bag \(2\).
- Put brick \(2\) into bag \(3\).

If Pak Chanek distributes the bricks that way, a way Bu Dengklek can take the bricks is:

- Take brick \(5\) from bag \(1\).
- Take brick \(3\) from bag \(2\).
- Take brick \(2\) from bag \(3\).

The score is \(|a_5 - a_3| + |a_3 - a_2| = |3 - 5| + |5 - 1| = 6\). It can be shown that Bu Dengklek cannot get a smaller score from this distribution.

It can be shown that there is no other distribution that results in a final score bigger than \(6\).

### 代码参考

## Show code

1 | /* |

## D - Knowledge Cards

Pak Chanek, a renowned scholar, invented a card puzzle using his knowledge. In the puzzle, you are given a board with \(n\) rows and \(m\) columns. Let \((r, c)\) represent the cell in the \(r\)-th row and the \(c\)-th column.

Initially, there are \(k\) cards stacked in cell \((1, 1)\). Each card has an integer from \(1\) to \(k\) written on it. More specifically, the \(i\)-th card **from the top** of the stack in cell \((1, 1)\) has the number \(a_i\) written on it. It is known that no two cards have the same number written on them. In other words, the numbers written on the cards are a permutation of integers from \(1\) to \(k\). All other cells are empty.

You need to move the \(k\) cards to cell \((n, m)\) to create another stack of cards. Let \(b_i\) be the number written on the \(i\)-th card **from the top** of the stack in cell \((n, m)\). You should create the stack in cell \((n, m)\) in such a way so that \(b_i = i\) for all \(1 \leq i \leq k\).

In one move, you can remove the **top card** from a cell and place it onto an adjacent cell (a cell that shares a common side). If the target cell already contains one or more cards, you place your card **on the top of the stack**. You must do each operation while satisfying the following restrictions:

- Each cell other than \((1,1)\) and \((n,m)\) must not have more than one card on it.
- You cannot move a card onto cell \((1,1)\).
- You cannot move a card from cell \((n,m)\).

Given the values of \(n\), \(m\), \(k\) and the array \(a\), determine if the puzzle is solvable.

### Input

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \leq t \leq 2 \cdot 10^4\)) — the number of test cases. The following lines contain the description of each test case.

The first line of each test case contains three integers \(n\), \(m\), and \(k\) (\(3 \leq n, m \leq 10^6\), \(nm \leq 10^6\), \(1 \leq k \leq 10^5\)) — the size of the board and the number of cards.

The second line of the test case contains \(k\) integers \(a_1, a_2, \ldots, a_k\) — the array \(a\), representing the numbers written on the cards. The values of \(a\) are a permutation of integers from \(1\) to \(k\).

It is guaranteed that the sum of \(nm\) and \(k\) over all test cases do not exceed \(10^6\) and \(10^5\) respectively.

### Output

For each test case, output "`YA`

" (without quotes) if it is possible and "`TIDAK`

" (without quotes) otherwise, which mean yes and no in Indonesian respectively.

You can output "`YA`

" and "`TIDAK`

" in any case (for example, strings "`tiDAk`

", "`tidak`

", and "`Tidak`

" will be recognised as a negative response).

### Example

#### input

1 | 4 |

#### output

1 | YA |

### Note

In the first test case, the following is one way the puzzle can be done:

- Move the card with \(3\) written on it from cell \((1, 1)\) to cell \((1, 2)\), then cell \((1, 3)\).
- Move the card with \(6\) written on it from cell \((1, 1)\) to cell \((2, 1)\), then cell \((3, 1)\), then cell \((3, 2)\), then cell \((3, 3)\).
- Move the card with \(4\) written on it from cell \((1, 1)\) to cell \((1, 2)\).
- Move the card with \(1\) written on it from cell \((1, 1)\) to cell \((2, 1)\), then cell \((2, 2)\), then cell \((2, 3)\).
- Move the card with \(2\) written on it from cell \((1, 1)\) to cell \((2, 1)\), then cell \((2, 2)\).
- Move the card with \(5\) written on it from cell \((1, 1)\) to cell \((2, 1)\), then cell \((3, 1)\), then cell \((3, 2)\), then cell \((3, 3)\).
- Move the card with \(2\) written on it from cell \((2, 2)\) to cell \((2, 1)\).
- Move the card with \(4\) written on it from cell \((1, 2)\) to cell \((2, 2)\), then cell \((3, 2)\), then cell \((3, 3)\).
- Move the card with \(3\) written on it from cell \((1, 3)\) to cell \((1, 2)\), then cell \((2, 2)\), then cell \((3, 2)\), then cell \((3, 3)\).
- Move the card with \(2\) written on it from cell \((2, 1)\) to cell \((3, 1)\), then cell \((3, 2)\), then cell \((3, 3)\).
- Move the card with \(1\) written on it from cell \((2, 3)\) to cell \((3, 3)\).

An animated illustration regarding the process mentioned above is as follows:

### 代码参考

## Show code

1 | /* |

## E - Hanging Hearts

Pak Chanek has \(n\) blank heart-shaped cards. Card \(1\) is attached directly to the wall while each of the other cards is hanging onto exactly one other card by a piece of string. Specifically, card \(i\) (\(i > 1\)) is hanging onto card \(p_i\) (\(p_i < i\)).

In the very beginning, Pak Chanek must write one integer number on each card. He does this by choosing any permutation \(a\) of \([1, 2, \dots, n]\). Then, the number written on card \(i\) is \(a_i\).

After that, Pak Chanek must do the following operation \(n\) times while maintaining a sequence \(s\) (which is initially empty):

- Choose a card \(x\) such that no other cards are hanging onto it.
- Append the number written on card \(x\) to the end of \(s\).
- If \(x \neq 1\) and the number on card \(p_x\) is larger than the number on card \(x\), replace the number on card \(p_x\) with the number on card \(x\).
- Remove card \(x\).

After that, Pak Chanek will have a sequence \(s\) with \(n\) elements. What is the maximum length of the longest non-decreasing subsequence\(^\dagger\) of \(s\) at the end if Pak Chanek does all the steps optimally?

\(^\dagger\) A sequence \(b\) is a subsequence of a sequence \(c\) if \(b\) can be obtained from \(c\) by deletion of several (possibly, zero or all) elements. For example, \([3,1]\) is a subsequence of \([3,2,1]\), \([4,3,1]\) and \([3,1]\), but not \([1,3,3,7]\) and \([3,10,4]\).

### Input

The first line contains a single integer \(n\) (\(2 \le n \le 10^5\)) — the number of heart-shaped cards.

The second line contains \(n - 1\) integers \(p_2, p_3, \dots, p_n\) (\(1 \le p_i < i\)) describing which card that each card hangs onto.

### Output

Print a single integer — the maximum length of the longest non-decreasing subsequence of \(s\) at the end if Pak Chanek does all the steps optimally.

### Examples

#### input

1 | 6 |

#### output

1 | 4 |

#### input

1 | 2 |

#### output

1 | 2 |

### Note

The following is the structure of the cards in the first example.

Pak Chanek can choose the permutation \(a = [1, 5, 4, 3, 2, 6]\).

Let \(w_i\) be the number written on card \(i\). Initially, \(w_i = a_i\). Pak Chanek can do the following operations in order:

- Select card \(5\). Append \(w_5 = 2\) to the end of \(s\). As \(w_4 > w_5\), the value of \(w_4\) becomes \(2\). Remove card \(5\). After this operation, \(s = [2]\).
- Select card \(6\). Append \(w_6 = 6\) to the end of \(s\). As \(w_2 \leq w_6\), the value of \(w_2\) is left unchanged. Remove card \(6\). After this operation, \(s = [2, 6]\).
- Select card \(4\). Append \(w_4 = 2\) to the end of \(s\). As \(w_1 \leq w_4\), the value of \(w_1\) is left unchanged. Remove card \(4\). After this operation, \(s = [2, 6, 2]\).
- Select card \(3\). Append \(w_3 = 4\) to the end of \(s\). As \(w_2 > w_3\), the value of \(w_2\) becomes \(4\). Remove card \(3\). After this operation, \(s = [2, 6, 2, 4]\).
- Select card \(2\). Append \(w_2 = 4\) to the end of \(s\). As \(w_1 \leq w_2\), the value of \(w_1\) is left unchanged. Remove card \(2\). After this operation, \(s = [2, 6, 2, 4, 4]\).
- Select card \(1\). Append \(w_1 = 1\) to the end of \(s\). Remove card \(1\). After this operation, \(s = [2, 6, 2, 4, 4, 1]\).

One of the longest non-decreasing subsequences of \(s = [2, 6, 2, 4, 4, 1]\) is \([2, 2, 4, 4]\). Thus, the length of the longest non-decreasing subsequence of \(s\) is \(4\). It can be proven that this is indeed the maximum possible length.

### 代码参考

## Show code

1 | /* |

## F - Conditional Mix

Pak Chanek is given an array \(a\) of \(n\) integers. For each \(i\) (\(1 \leq i \leq n\)), Pak Chanek will write the one-element set \(\{a_i\}\) on a whiteboard.

After that, in one operation, Pak Chanek may do the following:

- Choose two different sets \(S\) and \(T\) on the whiteboard such that \(S \cap T = \varnothing\) (\(S\) and \(T\) do not have any common elements).
- Erase \(S\) and \(T\) from the whiteboard and write \(S \cup T\) (the union of \(S\) and \(T\)) onto the whiteboard.

After performing zero or more operations, Pak Chanek will construct a multiset \(M\) containing the sizes of all sets written on the whiteboard. In other words, each element in \(M\) corresponds to the size of a set after the operations.

How many distinct\(^\dagger\) multisets \(M\) can be created by this process? Since the answer may be large, output it modulo \(998\,244\,353\).

\(^\dagger\) Multisets \(B\) and \(C\) are different if and only if there exists a value \(k\) such that the number of elements with value \(k\) in \(B\) is different than the number of elements with value \(k\) in \(C\).

### Input

The first line contains a single integer \(n\) (\(1 \le n \le 2000\)).

The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\) (\(1 \leq a_i \leq n\)).

### Output

Output the number of distinct multisets \(M\) modulo \(998\,244\,353\).

### Examples

#### input

1 | 6 |

#### output

1 | 7 |

#### input

1 | 7 |

#### output

1 | 11 |

### Note

In the first example, the possible multisets \(M\) are \(\{1,1,1,1,1,1\}\), \(\{1,1,1,1,2\}\), \(\{1,1,1,3\}\), \(\{1,1,2,2\}\), \(\{1,1,4\}\), \(\{1,2,3\}\), and \(\{2,2,2\}\).

As an example, let's consider a possible sequence of operations.

- In the beginning, the sets are \(\{1\}\), \(\{1\}\), \(\{2\}\), \(\{1\}\), \(\{4\}\), and \(\{3\}\).
- Do an operation on sets \(\{1\}\) and \(\{3\}\). Now, the sets are \(\{1\}\), \(\{1\}\), \(\{2\}\), \(\{4\}\), and \(\{1,3\}\).
- Do an operation on sets \(\{2\}\) and \(\{4\}\). Now, the sets are \(\{1\}\), \(\{1\}\), \(\{1,3\}\), and \(\{2,4\}\).
- Do an operation on sets \(\{1,3\}\) and \(\{2,4\}\). Now, the sets are \(\{1\}\), \(\{1\}\), and \(\{1,2,3,4\}\).
- The multiset \(M\) that is constructed is \(\{1,1,4\}\).

### 代码参考

## Show code

## G - Dangerous Laser Power

Pak Chanek has an \(n \times m\) grid of portals. The portal on the \(i\)-th row and \(j\)-th column is denoted as portal \((i,j)\). The portals \((1,1)\) and \((n,m)\) are on the north-west and south-east corner of the grid respectively.

The portal \((i,j)\) has two settings:

**Type**\(t_{i,j}\), which is either \(0\) or \(1\).**Strength**\(s_{i,j}\), which is an integer between \(1\) and \(10^9\) inclusive.

Each portal has \(4\) faces labelled with integers \(0,1,2,3\), which correspond to the north, east, south, and west direction respectively.

When a laser enters face \(k\) of portal \((i, j)\) with speed \(x_\text{in}\), it leaves the portal going out of face \((k+2+t_{i,j}) \bmod 4\) with speed \(x_\text{out} = \max(x_\text{in},s_{i,j})\). The portal also has to consume \(x_\text{out} - x_\text{in}\) units of **energy**.

Pak Chanek is very bored today. He will shoot \(4nm\) lasers with an initial speed of \(1\), one into each face of each portal. Each laser will travel throughout this grid of portals until it moves outside the grid or it has passed through \(10^{100}\) portals.

At the end, Pak Chanek thinks that a portal is **good** if and only if the total energy consumed by that portal modulo \(2\) is equal to its type. Given the strength settings of all portals, find a way to assign the type settings of each portal such that the number of good portals is maximised.

### Input

The first line contains two integers \(n\) and \(m\) (\(1 \le n, m \le 1000\)) — the number of rows and columns in the grid.

The \(i\)-th of the next \(n\) lines contains \(m\) integers, with the \(j\)-th integer being \(s_{i,j}\) (\(1 \leq s_{i,j} \leq 10^9\)) — the strength of portal \((i, j)\).

### Output

Print \(n\) lines with each line containing a string of length \(m\) consisting of characters \(0\) or \(1\) representing the type settings. The \(j\)-th character in the \(i\)-th string is the type setting of portal \((i, j)\).

If there are multiple solutions, you can output any of them.

### Examples

#### input

1 | 2 3 |

#### output

1 | 110 |

#### input

1 | 1 2 |

#### output

1 | 10 |

### Note

In the first example, let's consider the laser Pak Chanek shoots into face \(1\) of portal \((2, 2)\). The laser travels as follows:

- The laser enters face \(1\) of portal \((2, 2)\) with speed \(1\). It leaves the portal going out of face \(3\) with speed \(5\). Portal \((2, 2)\) consumes \(4\) units of energy.
- The laser enters face \(1\) of portal \((2, 1)\) with speed \(5\). It leaves the portal going out of face \(0\) with speed \(6\). Portal \((2, 1)\) consumes \(1\) units of energy.
- The laser enters face \(2\) of portal \((1, 1)\) with speed \(6\). It leaves the portal going out of face \(1\) with speed \(8\). Portal \((1, 1)\) consumes \(2\) units of energy.
- The laser enters face \(3\) of portal \((1, 2)\) with speed \(8\). It leaves the portal going out of face \(2\) with speed \(8\). Portal \((1, 2)\) consumes \(0\) units of energy.
- The laser enters face \(0\) of portal \((2, 2)\) with speed \(8\). It leaves the portal going out of face \(2\) with speed \(8\). Portal \((2, 2)\) consumes \(0\) units of energy.

The illustration of the travel of the laser above is as follows.

As an example, consider portal \((2, 3)\). We can calculate that the total energy consumed by that portal in the end will be \(32\). Since \(32 \bmod 2 = 0\) and \(t_{2,3} = 0\), then it is a good portal.

### 代码参考

## Show code

## H - MEX Tree Manipulation

Given a rooted tree, define the value of vertex \(u\) in the tree recursively as the MEX\(^\dagger\) of the **values of its children**. Note that it is only the children, not all of its descendants. In particular, the value of a leaf is \(0\).

Pak Chanek has a rooted tree that initially only contains a single vertex with index \(1\), which is the root. Pak Chanek is going to do \(q\) queries. In the \(i\)-th query, Pak Chanek is given an integer \(x_i\). Pak Chanek needs to add a new vertex with index \(i+1\) as the child of vertex \(x_i\). After adding the new vertex, Pak Chanek needs to recalculate the values of all vertices and report the sum of the values of all vertices in the current tree.

\(^\dagger\) The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For example, the MEX of \([0,1,1,2,6,7]\) is \(3\) and the MEX of \([6,9]\) is \(0\).

### Input

The first line contains a single integer \(q\) (\(1 \le q \le 3 \cdot 10^5\)) — the number of operations.

Each of the next \(q\) lines contains a single integer \(x_i\) (\(1 \leq x_i \leq i\)) — the description of the \(i\)-th query.

### Output

For each query, print a line containing an integer representing the sum of the new values of all vertices in the tree after adding the vertex.

### Examples

#### input

1 | 7 |

#### output

1 | 1 |

#### input

1 | 8 |

#### output

1 | 1 |

### Note

In the first example, the tree after the \(6\)-th query will look like this.

- Vertex \(7\) is a leaf, so its value is \(0\).
- Vertex \(6\) is a leaf, so its value is \(0\).
- Vertex \(5\) only has a child with value \(0\), so its value is \(1\).
- Vertex \(4\) is a leaf, so its value is \(0\).
- Vertex \(3\) only has a child with value \(0\), so its value is \(1\).
- Vertex \(2\) has children with values \(0\) and \(1\), so its value is \(2\).
- Vertex \(1\) has children with values \(1\) and \(2\), so its value is \(0\).

The sum of the values of all vertices is \(0+0+1+0+1+2+0=4\).

### 代码参考

## Show code

## I - Arranging Crystal Balls

In the world of Compfestnesia, Pak Chanek discovers a secret underground dungeon. Inside it, there is a treasure chest that is surrounded by \(n\) statues that are arranged in a circular manner. The statues are numbered from \(0\) to \(n-1\) with statue \(i\) being to the left of statue \(i+1\) and statue \(n-1\) being to the left of statue \(0\).

Pak Chanek observes that each statue is holding a crystal ball with an integer between \(0\) and \(m-1\) inclusive. Let's say the integer in the crystal ball of statue \(i\) is \(a_i\).

The dungeon provides instructions that every integer in the crystal balls must be \(0\) in order to open the treasure chest. To achieve that, Pak Chanek is given an integer \(k\), and he can do zero or more operations. In a single operation, Pak Chanek does the following:

- Choose exactly \(k\) consecutive statues. In other words, choose the statues \(p, (p+1) \bmod n, (p+2) \bmod n, (p+3) \bmod n, \ldots, (p+k-1) \bmod n\) for some chosen index \(p\).
- Do one of the following:
- For all chosen statues, change their values of \(a_i\) into \((a_i+1) \bmod m\).
- For all chosen statues, change their values of \(a_i\) into \((a_i-1) \bmod m\).

Help Pak Chanek find the minimum possible number of operations to open the treasure chest.

### Input

The first line contains three integers \(n\), \(m\), and \(k\) (\(2 \leq n,m \leq 10^6\), \(nm \leq 2 \cdot 10^6\), \(1 \leq k < n\)) — the number of statues, the bound of the integers in the crystal balls, and the number of statues that can be operated in a single operation.

The second line contains \(n\) integers \(a_0,a_1,\ldots,a_{n-1}\) (\(0 \leq a_i < m\)) — the integers in the crystal balls.

### Output

If it is possible to perform zero or more operations so that \(a_0=a_1=\ldots=a_{n-1}=0\), output the minimum number of operations required. Otherwise, output \(-1\).

### Examples

#### input

1 | 5 9 3 |

#### output

1 | 7 |

#### input

1 | 4 4 2 |

#### output

1 | -1 |

#### input

1 | 5 5 2 |

#### output

1 | 10 |

### Note

In the first example, Pak Chanek can do the following operations:

- Do the \(a_i := (a_i-1) \bmod m\) operation \(3\) times for statues \(1\), \(2\), and \(3\). Now \(a=[8,7,1,2,0]\).
- Do the \(a_i := (a_i-1) \bmod m\) operation \(1\) time for statues \(3\), \(4\), and \(0\). Now \(a=[7,7,1,1,8]\).
- Do the \(a_i := (a_i+1) \bmod m\) operation \(2\) times for statues \(4\), \(0\), and \(1\). Now \(a=[0,0,1,1,1]\).
- Do the \(a_i := (a_i-1) \bmod m\) operation \(1\) time for statues \(2\), \(3\), and \(4\). Now \(a=[0,0,0,0,0]\).