Problem: Texas Hold’em Training (Terminal I/O Interactive)

Time limit: 10 seconds
Memory limit: 512 MB

Overview
You will write a program that plays a large number of very simplified heads-up Texas Hold’em hands against a fixed opponent policy. The judge runs the game and reveals exactly the information you are allowed to know. Your program must decide whether to CHECK, FOLD, or RAISE an integer number of chips each betting round to maximize your chip profit. Interaction is via standard input/output (stdin/stdout). You must flush after every line you print.

Cards, ranks, and hand comparison
- Deck: 52 cards, 4 suits labeled 0,1,2,3. Each suit has 13 values labeled 1..13 corresponding to 2,3,4,5,6,7,8,9,T,J,Q,K,A (in strictly increasing order).
- A 5-card hand type ranking (highest to lowest):
  1) Straight flush (a straight with all five cards same suit)
  2) Four of a kind
  3) Full house (three of a kind + a pair)
  4) Flush (five cards same suit)
  5) Straight (five consecutive values; A-2-3-4-5 is valid and is the lowest straight; K-A-2-3-4 is not)
  6) Three of a kind
  7) Two pairs
  8) One pair
  9) High card
- Comparing two hands:
  - If hand types differ, higher type wins.
  - If both are straights or straight flushes: compare by the straight’s rank. Ten-to-Ace (T-J-Q-K-A) is the highest; A-2-3-4-5 is the lowest.
  - Otherwise, sort the 5 cards by the tuple (multiplicity, value) in descending order, where multiplicity is how many times the value appears in the hand. Compare these 5-card sequences lexicographically. Suits never break ties beyond determining flush/straight flush.
  - Examples:
    - Same-suit 5-6-7-8-9 > same-suit A-2-3-4-5.
    - Same-suit A-2-3-4-5 > same-suit 2-4-5-6-7 (the latter is not a straight).
    - 3-3-8-8-K > 5-5-7-7-A (two pairs with higher top pair/tiebreakers).
    - Q-Q-Q-T-T > J-J-J-A-A.
- Board-of-7 rule: At showdown each player forms their best 5-card hand from their 7 available cards (2 private + 5 community). The higher best 5-card hand wins; equal best hands tie.

Game flow (per hand)
- Shuffling and dealing:
  - The 52 cards are uniformly randomly permuted.
  - You (Alice) receive the top 2 cards; the opponent (Bob) receives the next 2 (unknown to you).
  - A “pot” starts with 10 chips. Both players start the hand with 100 chips behind (stacks). All chip counts are integers.
- Four betting rounds, with at most one action from you and one response from Bob per round:
  1) Round 1 (preflop): no community cards are visible.
  2) Reveal 3 community cards (the flop).
  3) Round 2.
  4) Reveal 1 community card (the turn).
  5) Round 3.
  6) Reveal 1 community card (the river).
  7) Round 4.
- Your options when it is your turn in any round:
  - CHECK: no chips move.
  - FOLD: the hand ends immediately; Bob wins the entire pot.
  - RAISE x: choose an integer x with 1 ≤ x ≤ your current stack; you move x chips into the pot.
- Bob’s response after your action:
  - If you CHECK: Bob always CHECKS (no bet this round).
  - If you RAISE x: Bob either FOLDs (you win the pot immediately) or CALLs (she moves x chips into the pot).
  - It is guaranteed Bob always has enough chips to call any allowed raise x (by construction of this single-raise-per-round process).
- Showdown and payouts:
  - If nobody folds by the end of Round 4, reveal all community cards (already visible) and both hole cards are implicitly known to the judge; the judge determines the winner using the rules above.
  - Winner gets the entire pot; if tie, the pot is split evenly (integer arithmetic; pot is always even here).
  - Your profit for the hand is (your ending stack) − 100. Positive means you won chips; negative means you lost chips.

Opponent policy (Bob)
- If you CHECK, she CHECKs.
- If you RAISE x, she compares:
  - EV(FOLD) = (her current stack) − 100.
  - EV(CALL) = estimated via 100 Monte Carlo rollouts:
    - Consider all yet-unseen cards (your hole cards are hidden from Bob, and unrevealed community cards are unknown).
    - For each rollout: take a uniform random permutation of the remaining unseen cards; assign them to all unknown positions in natural order (your hidden cards remain unknown to Bob but are assigned in the simulation; remaining community cards are dealt next).
    - Assume that after she calls now, you will CHECK in all future rounds (this is how she evaluates the call).
    - Compute her resulting profit in that simulation.
    - EV(CALL) is the average over the 100 rollouts.
  - She CALLs if and only if EV(CALL) > EV(FOLD); otherwise she FOLDs.

Terminal I/O protocol
All lines are plain ASCII tokens separated by spaces. You must flush after every line you print. If you ever read -1, you must exit immediately.

Start of the match
- Read a single integer G: the number of hands the judge will play (up to 10,000 in official tests).

Per-hand loop
The judge will drive the hand by repeatedly sending a STATE describing your next decision point. After a STATE, you may ask for Monte Carlo equity estimates, then you must output exactly one ACTION.

State description (from judge to you)
- STATE h r a b P k
  - h: 1-based hand index
  - r: current round in {1,2,3,4} (you act first in each round)
  - a: your current stack (chips behind)
  - b: Bob’s current stack
  - P: current pot size
  - k: number of currently revealed community cards; k ∈ {0,3,4,5}
- ALICE c1 v1 c2 v2
  - Your two hole cards as (suit, value) pairs; suit in [0..3], value in [1..13] for 2..A
- BOARD followed by 2k integers
  - Exactly k cards, each as (suit, value); if k = 0, the line is just “BOARD” with no numbers.

Optional helper query (from you to judge)
- RATE t
  - t: positive integer number of sampling rollouts the judge should use to estimate your win/draw rates from the current partial state (this mimics getRatesBySampling). The judge responds:
  - RATES w d
    - w: estimated probability that your final 7-card hand will be strictly better than Bob’s (double)
    - d: estimated probability of a tie (double)
  - The sampling completes the currently unknown cards (Bob’s hole, unrevealed community) uniformly at random from the remaining deck.
  - Global budget: sum of all t over the entire match must be ≤ 3,000,000. If you exceed this, the judge may reply with -1 and terminate. RATE does not advance the hand; you may issue multiple RATE queries per STATE within the budget.

Your decision (exactly one per STATE)
- ACTION CHECK
- ACTION FOLD
- ACTION RAISE x
  - x must be an integer with 1 ≤ x ≤ your current stack a.

Judge’s immediate response after your ACTION
- If ACTION CHECK:
  - OPP CHECK
  - If r < 4, dealing proceeds and you will receive the next STATE for round r+1 (with updated k = 3,4,5).
  - If r = 4, the hand ends by showdown; judge then prints RESULT delta.
- If ACTION RAISE x:
  - OPP FOLD
    - The hand ends immediately; judge prints RESULT delta (your profit for this hand).
  - or OPP CALL x
    - The hand continues. If r < 4, the judge proceeds to the next STATE (round r+1 with more community cards). If r = 4, the hand ends by showdown and judge prints RESULT delta.
- RESULT delta
  - delta is your integer profit for this hand: ending stack − 100. The next hand then begins (or the match ends if h = G).

End of the match
- After all G hands, the judge prints:
  - SCORE W
    - W is your average profit per hand (double), i.e., mean of all delta.

Validity and termination
- Any malformed command, out-of-range raise, or protocol violation may cause the judge to print -1 and terminate immediately; your program must exit upon reading -1.
- Always flush after printing RATE or ACTION (e.g., in C++: cout << line << endl; or fflush(stdout)).

Constraints and guarantees
- G ≤ 10,000 in official tests.
- Sum of t over all RATE queries ≤ 3,000,000.
- All chip movements are integers. Pot and stacks fit in 32-bit signed integers in all official tests.
- The hidden deck for each hand is fixed before the hand begins and does not depend on your queries.
- With this single-raise-per-round structure and symmetric stacks, Bob always has enough chips to CALL any legal RAISE you declare.

Scoring
Only programs that follow the protocol, do not exceed the RATE budget, and finish all hands are scored.

Let W be the final average profit per hand printed by the judge (the SCORE value). Your points are a piecewise-linear function of W:

- If W ≤ 8.0: score = 0.
- If 8.0 < W ≤ 11.0: score increases linearly from 0 to 40:
  score = round(13.3 × (W − 8)).
- If 11.0 < W ≤ 14.0: score increases linearly from 40 to 82:
  score = 40 + round(14 × (W − 11)).
- If 14.0 < W: score increases linearly from 82 to Infinite:
  score = 82 + round(3 × (W − 14)).

Interpretation:
- Around W ≥ 11 indicates you beat a simple baseline (roughly “Small Task”).
- Around W ≥ 16 indicates a strong strategy (roughly “Large Task”).

Example interaction (illustrative only)
Judge: 1
Judge: STATE 1 1 100 100 10 0
Judge: ALICE 0 12 2 1
Judge: BOARD
You: RATE 100
Judge: RATES 0.421000 0.010000
You: ACTION RAISE 5
Judge: OPP FOLD
Judge: RESULT 15
Judge: SCORE 15.000000

Notes and clarifications
- Card encoding:
  - Each card is printed as two integers: suit in [0..3], value in [1..13] corresponding to 2..A.
  - Community cards appear in deal order on BOARD (first the 3-card flop, then turn, then river).
- You do not need to implement hand evaluation to be correct; the judge handles showdowns. However, to plan your actions you may use RATE queries (within budget) or implement your own simulation/evaluation.
- Precision of RATES and SCORE is implementation-defined by the judge; treat them as doubles. Do not rely on a fixed number of decimals.
- If you ever read -1, exit immediately without printing anything further.

Strategy discussion (non-binding)
- The opponent’s CALL decision underestimates your future aggression (she assumes you will CHECK afterwards), which can be exploited by well-timed raises.
- RATE queries give you (win, tie) probabilities under random completions; combined with current pot and effective stacks, you can estimate immediate fold equity versus call equity to choose raise sizes.
- Budget your RATE calls: preflop and early-street coarse estimates (small t) and larger t near pivotal decisions can perform well within the 3,000,000 budget.

# Set the problem type to interactive
type: interactive

# Specify the interactor source file
interactor: interactor.cc

# Time and memory limits still apply to the contestant's solution
time: 100s
memory: 512m

# The subtasks section works the same way
subtasks:
  - score: 100
    n_cases: 3 # Looks for 1.in, 2.in, ... 5.in


Find Median

This is an interactive problem.

There is a hidden permutation p of length n, where n is even.
You are allowed to make queries by choosing a subsequence of indices with even length k (where 4 ≤ k ≤ n). For a chosen subsequence, the interactor will return the two median values.
For a subsequence of even length k, the two medians are defined as the k/2-th and (k/2+1)-th smallest values in that subsequence.

Your goal is to find the index of the two medians in permutation p. This problem is graded based on the number of queries you use. In order to receive any points, you must use no more than 500 queries. After that, your answer will be compared to a solution ref_queries. Your final score will be calculated as the average of 100 * min(ref_queries / your_queries, 1) across all cases.

Input

The first line contains a single integer n (6 ≤ n ≤ 100, n is even) — the length of the hidden permutation.

Interaction

To make a query, output one line in the following format:
0 k x1 x2 ... xk

where:
- k is the length of the subsequence (4 ≤ k ≤ n, k must be even)
- x1, x2, ..., xk are distinct indices between 1 and n

After each query, read a line containing two integers m1 and m2 (1 ≤ m1 < m2 ≤ n) — the two median values of the subsequence.

When you have found the answer, output one line in the following format:
1 i1 i2 - the index of the two medians.

After printing the answer, your program should terminate immediately.

Note: The interactor is non-adaptive. The permutation is fixed before you start querying.

To flush your output, use:
- fflush(stdout) or cout.flush() in C++
- System.out.flush() in Java
- stdout.flush() in Python

Example Interaction

Input:
6

3 4

3 4

2 3

Output:

0 6 1 2 3 4 5 6

0 4 3 6 1 5

0 4 3 6 2 5

1 3 6

Time limit: 4 seconds
Memory limit: 512 MB

type: interactive
interactor: interactor.cc
time: 4s
memory: 512m
subtasks:
  - score: 100
    n_cases: 3


# Meituan Cup Warm-up Problem — Number Loop

This year's Meituan Cup warm-up problem is a **Number Loop**.

When designing this problem, Suanxie first selected the following template, ensuring that the puzzle must contain the two patterns **MT** and **PKU**.

The next step is to replace all `?` in the template with digits from `0` to `3`, thus forming a valid Number Loop puzzle. An important requirement is that the puzzle must have a **unique solution** (the definition of a solution can be found in the warm-up problem).

However, Suanxie found that creating a puzzle of suitable difficulty with a unique solution on this template was extremely challenging. Therefore, he temporarily modified the template, which resulted in the final warm-up problem used in the contest.

Although he eventually managed to produce a valid puzzle, the feeling of failure still bothered him. Now, he hopes that you can help him achieve his original goal — **to construct a unique-solution Number Loop puzzle based on the original template.**

---

## Problem Description

You need to construct a valid Number Loop puzzle according to the given input type.

* If the input is `0`, this corresponds to the **Small Task**: replace all `?` in the template with integers from `0` to `3`, ensuring the resulting puzzle has a **unique solution**.
* If the input is `1`, this corresponds to the **Large Task**: replace all `?` in the template with integers from `1` to `3`, ensuring the resulting puzzle has a **unique solution**.

Your program should output a $12\times12$ grid consisting only of spaces and digits `0`–`3`, representing the constructed puzzle. Each row of the grid corresponds to one line of output (including spaces).

---

## Input Format

The input contains a single integer:

* `0` — requires output of the Small Task solution.
* `1` — requires output of the Large Task solution.

---

## Output Format

Output a $12\times12$ character matrix containing only spaces and digits `0`–`3`, representing your constructed Number Loop puzzle.

---

## Sample Output

Below is a sample output (note that this example has **multiple solutions** and therefore does **not** satisfy the problem requirement; it is shown only to illustrate the format):

```
0   0   000
00 00  0   0
0 0 0  0   0
0 0 0  0000
0 0 0  0
0   0  0

0  0   00000
0 0      0
00   0 0 0
0 0  0 0 0
0  0 000 0
```

type: default

time: 3s
memory: 1024m

checker: checker.cpp
cheker_type: testlib
subtasks:
  - score: 100
    n_cases: 2


Problem Statement
--------
AtCoder has decided to place web advertisements of $n$ companies on the top page.
The space for placing advertisements is a square of size 10000 x 10000.
The space for each company must be an axis-parallel rectangle with positive area, and the coordinates of the vertices must be integer values.
Different rectangles may touch on their sides, but they must not overlap. In other words, the common area must not have positive area.
It is allowed to leave some free space that does not belong to any ad.

President Takahashi asked each company for their desired location and area. Company $i$ wants an ad space with area $r_i$ including point $(x_i+0.5, y_i+0.5)$.
The satisfaction level $p_i$ of company $i$ is determined as follows.

- If the ad space for company $i$ does not contain the point $(x_i+0.5, y_i+0.5)$, then $p_i = 0$.
- If the ad space for company $i$ contains the point $(x_i+0.5, y_i+0.5)$ and the area is $s_i$, then $p_i = 1 - (1 - \min(r_i,s_i) / \max(r_i, s_i))^2$.

Your task is to determine the placement of the ads so that the sum of the satisfaction levels is maximized.
You will get a score of $10^9 \times \sum_{i=0}^{n-1} p_i / n$ rounded to the nearest integer.

![](./images/dbec47df66576ff9e5b5ace9df6d9110.png "Visualization of Sample Output")

Input
--------
Input is given from Standard Input in the following format:

~~~
$n$
$x_0$ $y_0$ $r_0$
$\vdots$
$x_{n-1}$ $y_{n-1}$ $r_{n-1}$
~~~

- $50\leq n\leq 200$
- $x_i$ and $y_i$ are integers satisfying $0\leq x_i\leq 9999$ and $0\leq y_i\leq 9999$. For any $i\neq j$, $(x_i,y_i)\neq (x_j,y_j)$ holds.
- $r_i$ is an integer at least one and satisfies $\sum_{i=0}^{n-1} r_i=10000\times 10000$.

Output
--------
Let $(a_i, b_i)$ and $(c_i, d_i)$ ($0\leq a_i<c_i\leq 10000$, $0\leq b_i<d_i\leq 10000$) be the coordinates of the two diagonal vertices of the rectangle representing the ad space for company $i$.
Output to standard output in the following format.

~~~
$a_0$ $b_0$ $c_0$ $d_0$
$\vdots$
$a_{n-1}$ $b_{n-1}$ $c_{n-1}$ $d_{n-1}$
~~~

Input Generation
--------
Let $rand()$ be a function that generates a uniformly random double-precision floating point number at least zero and less than one.

#### Generation of $n$
The number of companies $n$ is generated by rounding $50 × 4^{rand()}$ to the nearest integer value.

#### Generation of $x_i$ and $y_i$
The list of desired locations $(x_1,y_i),\ldots,(x_n,y_n)$ is generated by randomly sampling $n$ distinct coordinates from $\\{(x, y) \mid x\in \\{0,1,\ldots,9999\\}, y\in\\{0,1,\ldots,9999\\}\\}$.

#### Generation of $r_i$
Let $q_1,\ldots,q_{n-1}$ be a sorted list of $n-1$ distinct integers randomly sampled from $\\{1,2,\ldots,99999999\\}$.
Let $q_0=0$ and $q_n=100000000$.
Then $r_i=q_{i+1}-q_i$.

Number of test cases
--------
- Provisional test: 50
- System test: 1000. We will publish seeds.txt (md5=8fc1ce3f4beabac6abc1bdb4206d7f7e) after the contest is over.

The score of a submission is the total scores for each test case.
In the provisional test, if your submission produces illegal output or exceeds the time limit for some test cases, the submission itself will be judged as WA or TLE, and the score of the submission will be zero.
In the system test, if your submission produces illegal output or exceeds the time limit for some test cases, only the score for those test cases will be zero.

Tools
--------
You can download an input generator and visualizer here.
To use them, you need a compilation environment of Rust language.

{sample example}

type: default
checker: chk.cc

# Time and memory limits still apply to the contestant's solution
time: 10s
memory: 256m

# The subtasks section works the same way
subtasks:
- score: 100
  n_cases: 3


Problem Statement
--------
There is a floor consisting of $50\times 50$ squares.
The floor is covered with rectangular tiles without any gaps.
Each tile has a size of either $1\times 1$, $1\times 2$, or $2\times 1$ squares.
Let $(0, 0)$ denote the top-left square, and $(i, j)$ denote the square at the $i$-th row from the top and $j$-th column from the left.
Takahashi starts from $(si, sj)$ and walks along a path satisfying the following conditions.

- From $(i, j)$, he can move to $(i-1,j)$, $(i+1,j)$, $(i,j-1)$, or $(i,j+1)$ in one step.
- He can step on the same tile only once. The tile at the initial position is assumed to have already been stepped on.

Each square has an integer value, and the score of a path is the sum of the values of the visited squares, including the square at the initial position.
Your goal is to find a path with as high a score as possible.

Examples
--------

Of the above three figures, only the path in the left figure satisfies the conditions.
In the middle figure, the same tile is stepped on twice in a row.
In the right figure, he left a tile once and then came back to the same tile.

Visualization result of the sample output.
The red circle represents the initial position, and the green circle represents the final position.
The tiles stepped on are painted in light blue.

Scoring
--------
The score of the output path is the score for the test case.
If the output does not satisfy the conditions, it is judged as `WA`.
There are 100 test cases, and the score of a submission is the total score for each test case.
If you get a result other than `AC` for one or more test cases, the score of the submission will be zero.
The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest.
If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Input
--------
Input is given from Standard Input in the following format:

~~~
$si$ $sj$
$t_{0,0}$ $t_{0,1}$ $\ldots$ $t_{0,49}$
$\vdots$
$t_{49,0}$ $t_{49,1}$ $\ldots$ $t_{49,49}$
$p_{0,0}$ $p_{0,1}$ $\ldots$ $p_{0,49}$
$\vdots$
$p_{49,0}$ $p_{49,1}$ $\ldots$ $p_{49,49}$
~~~

- $(si,sj)$ denotes the initial position and satisfies $0\leq si,sj\leq 49$.
- $t_{i,j}$ is an integer representing the tile placed on $(i,j)$. $(i,j)$ and $(i',j')$ are covered by the same tile if and only if $t_{i,j}=t_{i',j'}$ holds. Let the total number of tiles be $M$, then $0\leq t_{i,j}\leq M-1$ is satisfied.
- $p_{i,j}$ is an integer value satisfying $0\leq p_{i,j}\leq 99$ which represents the score obtained when visiting $(i,j)$.

Output
--------
Let `U`, `D`, `L`, and `R` represent the movement from $(i,j)$ to $(i-1,j)$, $(i+1,j)$, $(i,j-1)$, and $(i,j+1)$, respectively.
Output a string representing a path in one line.

Input Generation
--------
#### Generation of $si,sj$
Generate an integer between $0$ and $49$ uniformly at random.

#### Generation of $t_{i,j}$
We start from an initial configuration where tiles of size $1\times 1$ are placed on all squares.
We shuffle the 50x50 squares in random order and perform the following process for each square in order.

- If the tile placed on the current square is $1\times 1$, we randomly select one of the adjacent squares whose tile is $1\times 1$ and connect the two tiles into one tile. If there are no such adjacent squares, we do nothing.
- If the tile placed on the current square is not $1\times 1$, we do nothing.

#### Generation of $p_{i,j}$
Generate an integer between $0$ and $99$ uniformly at random independently for each square.

Tools
--------
- Inputs: A set of 100 inputs (seed 0-99) for local testing, including the sample input (seed 0). These inputs are different from the actual test case.
- Visualizer on the web
- Input generator and visualizer: If you want to use more inputs, or if you want to visualize your output locally, you can use this program. You need a compilation environment of Rust language.

{sample example}


Story
--------
AtCoder is developing a route navigation application that utilizes shortest path algorithms.
The service area is represented as a road network of 30x30 vertices connected in a grid.
When a user specifies the vertex of the current location and the vertex of the destination, the app will output the shortest path between them.
The trouble is that, even though the scheduled release date is approaching, the measurement of the length of each edge, which is essential for shortest path computations, is not finished at all.
Therefore, AtCoder decided to give up measuring the edge length in advance and allows the app to output paths that are not the shortest.
It should be possible to gradually improve the performance by estimating the length of each edge based on the information about the actual time users take to arrive at their destinations.

Problem Statement
--------
There is an undirected grid graph with 30x30 vertices with unknown edge lengths.
Let $(0, 0)$ denote the top-left vertex, and $(i, j)$ denote the vertex at the $i$-th row from the top and $j$-th column from the left.
Your task is to process the following query 1000 times.

In the $k$-th query, your program first receives the vertices $s_k=(si_k,sj_k)$ and $t_k=(ti_k,tj_k)$ from Standard Input in the following format:

~~~
$si_k$ $sj_k$ $ti_k$ $tj_k$
~~~

Then, your program should compute a path $P_k$ from $s_k$ to $t_k$.
Let `U`, `D`, `L`, and `R` represent the movement from $(i,j)$ to $(i-1,j)$, $(i+1,j)$, $(i,j-1)$, and $(i,j+1)$, respectively.
Output a string representing the path $P_k$ to Standard Output in one line.
**After the output, you have to flush Standard Output.** Otherwise, the submission might be judged as TLE.

After your program outputs a path, the judge program calculates the length $b_k$ of the path, generates a uniform random number $e_k$ between $0.9$ and $1.1$, and gives an integer value $\mathrm{round}(b_k\times e_k)$ to Standard Input.
By reading that integer, the $k$-th query completes, and you should proceed to the $k+1$-th query.

Examples
-----------------

Input
Output

3 19 16 17

DDDDDDDDDDDDDLL

99561

26 18 13 18

UUUUUUUUUUUUU

72947

Scoring
--------
Let $a_k$ and $b_k$ be the lengths of the shortest path and the output path for the $k$-th query ($1\leq k\leq 1000$), respectively.
Then the score for the test case is

$\mathrm{round}(2312311\times \sum_{k=1}^{1000}0.998^{1000-k} \frac{a_k}{b_k})$

The score of a submission is the total score for each test case.
If your program outputs an illegal path (visiting the same vertex multiple times, going outside of 30x30, or not a path from $s$ to $t$), it is judged as `WA`.
After the contest is over, the final ranking will be determined by system tests against the last submission.

- Provisional tests consist of 100 test cases. If you get a result other than `AC` for one or more test cases, the score of the submission will be zero.
- System tests consist of 3000 test cases. If you get a result other than `AC` for some test cases, only the score for those test cases will be zero. We will publish seeds.txt (md5=0cf5051d586e7f62c0b3527f6f7fbb1c) after the contest is over.

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniformly random integer between $L$ and $U$, inclusive.
We first generate two parameters $D=\mathrm{rand}(100, 2000)$ and $M=\mathrm{rand}(1, 2)$.
Let $h_{i,j}$ be the length of the edge between $(i, j)$ and $(i,j+1)$, and let $v_{i,j}$ be the length of the edge between $(i, j)$ and $(i+1,j)$.

#### Generation of $h_{i,j}$
1. For each $i\in\\{0,\ldots,29\\}$ and $p\in\\{0,\ldots,M-1\\}$, we independently generate a random integer $H_{i,p}=\mathrm{rand}(1000+D,9000-D)$.
2. For each $i\in\\{0,\ldots,29\\}$ and $j\in\\{0,\ldots,28\\}$, we independently generate a random integer $\delta_{i,j}=\mathrm{rand}(-D,D)$.
3. If $M=1$, for each $i\in\\{0,\ldots,29\\}$ and $j\in\\{0,\ldots,28\\}$, we set $h_{i,j}=H_{i,0}+\delta_{i,j}$.
4. If $M=2$, for each $i\in\\{0,\ldots,29\\}$, we generate a random integer $x_i=\mathrm{rand}(1,28)$, and then for each $j\in\\{0,\ldots,x_i-1\\}$, we set $h_{i,j}=H_{i,0}+\delta_{i,j}$, and for each $j\in\\{x_i,\ldots,28\\}$, we set $h_{i,j}=H_{i,1}+\delta_{i,j}$.

#### Generation of $v_{i,j}$
1. For each $j\in\\{0,\ldots,29\\}$ and $p\in\\{0,\ldots,M-1\\}$, we independently generate a random integer $V_{j,p}=\mathrm{rand}(1000+D,9000-D)$.
2. For each $i\in\\{0,\ldots,28\\}$ and $j\in\\{0,\ldots,29\\}$, we independently generate a random integer $\gamma_{i,j}=\mathrm{rand}(-D,D)$.
3. If $M=1$, for each $j\in\\{0,\ldots,29\\}$ and $i\in\\{0,\ldots,28\\}$, we set $v_{i,j}=V_{j,0}+\gamma_{i,j}$.
4. If $M=2$, for each $j\in\\{0,\ldots,29\\}$, we generate a random integer $y_j=\mathrm{rand}(1,28)$, and then for each $i\in\\{0,\ldots,y_j-1\\}$, we set $v_{i,j}=V_{j,0}+\gamma_{i,j}$, and for each $i\in\\{y_j,\ldots,28\\}$, we set $v_{i,j}=V_{j,1}+\gamma_{i,j}$.

#### Generation of $s_k$, $t_k$
The vertices $s_k$ and $t_k$ given in the query are chosen uniformly at random among all the vertices.
If the Manhattan distance between $s_k$ and $t_k$ ($|si_k-ti_k|+|sj_k-tj_k|$) is strictly less than 10, we repeat the random selection until the distance becomes at least 10.

Tools
--------
- Local tester: You need a compilation environment of Rust language.
- Visualizer
- Inputs: If you don't use the above local tester, you can instead use these 100 inputs (seed 0-99) for local testing. These inputs are different from the actual test cases. The inputs are in the following format, and you can use them by writing a judge program by yourself.

~~~
$h_{0,0}$ $\ldots$ $h_{0,28}$
$\vdots$
$h_{29,0}$ $\ldots$ $h_{29,28}$
$v_{0,0}$ $\ldots$ $v_{0,29}$
$\vdots$
$v_{28,0}$ $\ldots$ $v_{28,29}$
$si_1$ $sj_1$ $ti_1$ $tj_1$ $a_1$ $e_1$
$\vdots$
$si_{1000}$ $sj_{1000}$ $ti_{1000}$ $tj_{1000}$ $a_{1000}$ $e_{1000}$
~~~

#### Example of judge program (pseudo code)
~~~
string query(s, t, prev_result) {
	// WRITE YOUR SOLUTION HERE
}

int main() {
	if (LOCAL_TEST) {
		read_h_v();
	}
	prev_result = 0;
	score = 0.0;
	for (int k = 0; k < 1000; k++) {
		if (LOCAL_TEST) {
			read_s_t_a_e();
		} else {
			read_s_t();
		}
		path = query(s, t, prev_result);
		print(path);
		if (LOCAL_TEST) {
			b = compute_path_length(path);
			score = score * 0.998 + a / b;
			prev_result = round(b * e);
		} else {
			prev_result = read_result();
		}
	}
	if (LOCAL_TEST) {
		print(round(2312311 * score));
	}
	return 0;
}
~~~

type: interactive
interactor: interactor.cc

# Time and memory limits still apply to the contestant's solution
time: 10s
memory: 256m

# The subtasks section works the same way
subtasks:
- score: 100
  n_cases: 3


Problem Statement

You are given a sequence p of length n, which is a permutation of the numbers 1, 2, ..., n.

Your goal is to make the permutation lexicographically as small as possible by performing a specific operation at most 4n times, and then minimize the number of operations needed to reach that.
More specifically, you must do operations to get the lexicographically smallest permutation that's possible after 4n operations, and then you will be scored based on the number of operations needed to reach it.
Your final score will be calculated as the average of 100 * clamp((4 * n - your_operations)/(4 * n - best_operations), 0, 1) across all cases

The Operation

You can cut the sequence into three consecutive non-empty parts and swap the first part with the last part.

Formally, you select two integers x and y that represent the lengths of the prefix and suffix, respectively. These integers must satisfy:

    x > 0

    y > 0

    x + y < n

This splits the sequence into [Prefix | Middle | Suffix]. The operation transforms the sequence to [Suffix | Middle | Prefix].

Input

The first line contains an integer n, the length of the permutation.
The second line contains n space-separated integers, p_1, p_2, ..., p_n.

Output

On the first line, print an integer m, the total number of operations you performed.
On the following m lines, print the two integers x and y you chose for each operation, separated by a space.

Constraints

    3 <= n <= 1000

    The input sequence p is guaranteed to be a valid permutation.

type: default
# The time limit is now 1 second.
time: 1s
memory: 512m
# A custom checker is required for the special scoring.
checker: chk.cc
subtasks:
  - score: 100
    n_cases: 3


Story
--------
Human genetic information is recorded in DNA with a double helix structure and is represented by a very long string consisting of four characters, `A`, `G`, `C`, and `T`.
Recently, alien cells were found in a meteorite.
As a result of research, it was found that the genetic information of this alien is recorded in a torus-shaped material and is represented as an $N\times N$ matrix consisting of eight characters, `A`, `B`, `C`, `D`, `E`, `F`, `G`, and `H`.
Existing devices have failed to read this matrix directly, but they have succeeded in reading many one-dimensional subsequences that are contiguous vertically or horizontally.
Please estimate the matrix based on this information.

Problem Statement
--------
We define that a one-dimensional sequence $b=(b_0, \ldots, b_{k-1})$ is a **subsequence** of a matrix $a=(a_{i,j})_{0\leq i,j\leq N-1}$ if and only if there exists $(i, j)$ satisfying at least one of the following two conditions:

- For all $p=0,\ldots,k-1$, $b_p=a_{i,(j+p)\bmod N}$ holds. (horizontal match)
- For all $p=0,\ldots,k-1$, $b_p=a_{(i+p)\bmod N,j}$ holds. (vertical match)

Note that if the index is greater than or equal to $N$, we take the remainder divided by $N$ (in other words, $a$ is connected at the left and right ends, and the top and bottom ends).

Given $M$ strings $s_1, \ldots, s_M$ consisting of eight characters, `A`, `B`, $\ldots$, `H`, your goal is to find an $N\times N$ matrix consisting of characters `A`, `B`, $\ldots$, `H`, or `.` which contains as many of the given strings as possible as subsequences.
Here, `.` indicates an empty.

Scoring
--------
Let $c$ ($\leq M$) be the number of $i$'s such that $s_i$ is a subsequence of the output matrix, and let $d$ ($\leq N^2$) be the number of `.` contained in the output.
Then, you will obtain the following score.

- If $c<M$, $\mathrm{round}(10^8\times \frac{c}{M})$.
- If $c=M$, $\mathrm{round}(10^8\times \frac{2 N^2}{2 N^2-d})$.

If the output is illegal (not an $N\times N$ matrix, or containing a character other than `A`, `B`, $\ldots$, `H`, `.`), it is judged as `WA`.
There are 100 test cases, and the score of a submission is the total score for each test case.
If you get a result other than `AC` for one or more test cases, the score of the submission will be zero. The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest.
If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Input
--------
Input is given from Standard Input in the following format:

~~~
$N$ $M$
$s_1$
$\vdots$
$s_M$
~~~

- $N$ is fixed to 20 throughout all the test cases.
- $M$ is an integer satisfying $400\leq M\leq 800$.
- Each $s_i$ is a string consisting of characters `A`, `B`, $\ldots$, `H`, and its length is at least 2 and at most 12.

Output
--------
Output $N$ lines, each containing a string of length exactly $N$ consisting of characters `A`, `B`, $\ldots$, `H`, or `.`.

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniformly random integer between $L$ and $U$, inclusive.

We first generate an $N\times N$ matrix $a=(a_{i,j})_{0\leq i,j\leq N-1}$ by generating each element uniformly randomly from `A`, `B`, $\ldots$, `H`.
We then generate a parameter $L=\mathrm{rand}(4, 10)$, which decides the average length of the strings, and the number of strings $M=\mathrm{rand}(400, 800)$.
We generate $M$ strings $s_1,\ldots,s_M$ by repeating the following process $M$ times.

We generate two integers $i=\mathrm{rand}(0, N-1)$ and $j=\mathrm{rand}(0, N-1)$ representing a starting point, an integer $d=\mathrm{rand}(0,1)$ representing a direction, and an integer $k=\mathrm{rand}(L-2, L+2)$ representing the length of the string.

- If $d=0$, we choose a horizontal subsequence $(a_{i,j},a_{i,(j+1)\bmod N},\ldots,a_{i,(j+k-1)\bmod N})$.
- If $d=1$, we choose a vertical subsequence $(a_{i,j},a_{(i+1)\bmod N,j},\ldots,a_{(i+k-1)\bmod N,j})$.

Tools
--------
- Inputs: A set of 100 inputs (seed 0-99) for local testing, including the sample input (seed 0). These inputs are different from the actual test cases.
- Visualizer on the web
- Input generator and visualizer: If you want to use more inputs, or if you want to visualize your output locally, you can use this program. You need a compilation environment of Rust language.

{sample example}


Story
--------
To solve the shortage of police officers, the Takahashi City Police Department has decided to introduce automated patrols with unmanned patrol cars.
The unmanned patrol car is equipped with a high-resolution omnidirectional camera on the roof, which can see the entire road at once in a straight line from the current position. And then, it uses image processing technology to automatically detect suspicious activities.
In order to provide a safe and secure life for the citizens, we want to set up a patrol route that allows the patrol car to see every corner of the city at least once.
Among such patrol routes, please find as short a one as possible.

Problem Statement
--------
You are given a map consisting of $N\times N$ squares.
Let $(0,0)$ denote the top-left square, and $(i,j)$ denote the square at the $i$-th row from the top and $j$-th column from the left.
Each square is either an obstacle (`#`) or a road, and you can move up, down, left, or right on the road squares.
Each road square contains a number `5`-`9`, which represents the amount of time you take to move from an adjacent square to that square.
We define that a road square $(i',j')$ is visible from $(i,j)$ if and only if the following conditions are satisfied:

- $i=i'$ and for every $j''$ with $\min(j,j')\leq j''\leq\max(j,j')$, $(i,j'')$ is a road square, or
- $j=j'$ and for every $i''$ with $\min(i,i')\leq i''\leq\max(i,i')$, $(i'',j)$ is a road square.

For example, in the figure below, the gray squares represent obstacles, the white and light yellow squares represent roads, and the road squares that are visible from the green circle are colored light yellow.

![](./images/1bc7c896310a65486d0ce3aa275f41b7.png "Example of visible squares")

Your task is to find a route starting from a specified square $(si,sj)$, moving up, down, left, or right on road squares, and returning to $(si,sj)$, such that all the road squares become visible at least once.
The shorter the route, the higher the score.
You can move on the same square multiple times and even make a U-turn.

Scoring
--------
Let $r$ be the total number of road squares, $v$ be the number of road squares that become visible at least once, and $t$ be the total travel time of the output route. Then you will obtain the following score.

- If $v<r$, $\mathrm{round}(10^4\times \frac{v}{r})$.
- If $v=r$, $\mathrm{round}(10^4+10^7\times \frac{N}{t})$.

If the output is illegal (going out of $N\times N$ squares, moving on obstacle squares, or not returning to $(si,sj)$), it will be judged as `WA`.
There are 100 test cases, and the score of a submission is the total score for each test case. If you get a result other than `AC` for one or more test cases, the score of the submission will be zero. The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest. If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Input
--------
Input is given from Standard Input in the following format:

~~~
$N$ $si$ $sj$
$c_0$
$\vdots$
$c_{N-1}$
~~~

- $N$ is an odd integer between $49$ and $69$, inclusive.
- $si, sj$ are integers satisfying $0\leq si\leq N-1$ and $0\leq sj\leq N-1$.
- Each $c_i$ is a string of length exactly $N$ consisting of characters `5`, `6`, `7`, `8`, `9`, and `#`. The $j$-th character ($0\leq j\leq N-1$) represents the square $(i,j)$ as follows.
	- `#` means that the square contains an obstacle. It is guaranteed that $(si, sj)$ does not contain obstacles.
	- `5`-`9` show that the square is a road, and the number represents the amount of time you take to move from an adjacent square to that square.

Output
--------
Let `U`, `D`, `L`, and `R` represent the movement from $(i, j)$ to $(i-1,j)$, $(i+1,j)$, $(i,j-1)$, and $(i,j+1)$, respectively.
Output a string representing the route to Standard Output in one line.

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniformly random integer between $L$ and $U$, inclusive.
We first generate an odd integer $N=\mathrm{rand}(25, 35)\times 2 - 1$ which represents the size of the map and a parameter $K=\mathrm{rand}(2 N, 4 N)$ which represents the number of roads.
Starting from an initial map where all squares are obstacles, we repeat the following procedure $K$ times.

1. Generate an integer $d=\mathrm{rand}(0, 1)$ representing the direction of the road.
1. Generate two integers $i=\mathrm{rand}(0, (N-1)/2)\times 2$ and $j=\mathrm{rand}(0, N-1)$ representing the center of the road.
1. Generate an integer $h=\mathrm{rand}(3, 10)$ representing the length of the road.
1. Generate an integer $w=\mathrm{rand}(5, 9)$ representing the travel time.
1. For each $k$ with $\max(j-h,0)\leq k\leq \min(j+h,N-1)$, we overwrite square $(i,k)$ when $d=0$ or square $(k,i)$ when $d=1$ with a road square with travel time $w$.

After the repetition, we keep only the largest connected component of road squares and replace the rest with obstacles.
Finally, we select $(si,sj)$ uniformly at random from the road squares.

Tools
--------
- Inputs: A set of 100 inputs (seed 0-99) for local testing, including the sample input (seed 0). These inputs are different from the actual test cases.
- Visualizer on the web
- Input generator and visualizer: If you want to use more inputs, or if you want to visualize your output locally, you can use this program. You need a compilation environment of Rust language.

{sample example}


Problem Statement
--------
AtCoder Inc. operates a food delivery service, AtCoder Foods, that leisurely delivers food that tastes good even if it gets cold.
This service receives a large number of delivery orders in advance, and processes multiple deliveries simultaneously to improve efficiency.
The current service area is represented as a square area $\\{(x,y)\mid 0\leq x, y\leq 800\\}$ on a two-dimensional plane, with AtCoder's office located at the center $(400, 400)$.
There are 1000 orders today, and the $i$ ($1\leq i\leq 1000$)-th order is a food delivery request from a restaurant in $(a_i, b_i)$ to a location in $(c_i, d_i)$.

Today's quota for Takahashi, a delivery man, is to process 50 orders.
He can freely choose a subset $S\subseteq\\{1,\cdots,1000\\}$ of size exactly 50 from the 1000 orders and deliver on a route $(x_1,y_1),\cdots,(x_n,y_n)$ satisfying the following conditions.

1. For each $i\in S$, visit $(c_i, d_i)$ after visiting $(a_i,b_i)$. That is, there exists an integer pair $(s, t)$ such that $(x_s,y_s)=(a_i,b_i)$, $(x_t,y_t)=(c_i,d_i)$, and $s<t$.
2. $(x_1,y_1)=(x_n,y_n)=(400, 400)$.

After picking up food at one restaurant, he may pick up food at another restaurant or deliver food to another destination before delivering that food to the destination.
He is so powerful that he can carry arbitrary numbers of dishes simultaneously.

Moving from $(x_i,y_i)$ to $(x_{i+1},y_{i+1})$ takes time equal to the Manhattan distance $|x_i-x_{i+1}|+|y_i-y_{i+1}|$, and
the total travel time for the delivery route is $T=\sum_{i=1}^{n-1} |x_i - x_{i+1}|+|y_i - y_{i+1}|$.
Please optimize $S$ and delivery routes so that the total travel time is as short as possible.

Scoring
--------
For the total travel time $T$ of the output delivery route, you will get a score of $\mathrm{round}(10^8/(1000+T))$.

There are 100 test cases, and the score of a submission is the total score for each test case. If you get a result other than AC for one or more test cases, the score of the submission will be zero. The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest. If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Input
--------
Input is given from Standard Input in the following format:

~~~
$a_1$ $b_1$ $c_1$ $d_1$
$\vdots$
$a_{1000}$ $b_{1000}$ $c_{1000}$ $d_{1000}$
~~~

Each $a_i, b_i, c_i, d_i$ is an integer between $0$ and $800$, inclusive, where $(a_i, b_i)$ represents the coordinates of the restaurant, and $(c_i, d_i)$ represents the coordinates of the destination.
$(a_i,b_i)\neq (c_i,d_i)$ is satisfied, but for different orders $j$, there is a possibility that $\\{(a_i,b_i),(c_i,d_i)\\}\cap\\{(a_j,b_j),(c_j,d_j)\\}\neq\emptyset$.

Output
--------
Let the set of chosen orders be $r_1,\cdots,r_m$ ($1\leq r_i\leq 1000$), and the delivery route be $(x_1,y_1),\cdots,(x_n,y_n)$ ($0\leq x_i,y_i\leq 800$), output to Standard Output in the following format.

~~~
$m$ $r_1$ $\cdots$ $r_m$
$n$ $x_1$ $y_1$ $\cdots$ $x_n$ $y_n$
~~~

You may output multiple times for visualization purposes.
If your program outputs multiple times, only the last output will be used for scoring.
The final output must satisfy $m=50$, but intermediate outputs with $m\neq 50$ are allowed for visualization.

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniform random integer between $L$ and $U$, inclusive.
For each $i=1,\cdots,1000$, we generate an order $(a_i, b_i, c_i, d_i)$ as follows.

We generate $a_i=\mathrm{rand}(0, 800)$, $b_i=\mathrm{rand}(0, 800)$, $c_i=\mathrm{rand}(0, 800)$, and $d_i=\mathrm{rand}(0, 800)$.
Redo the generation as long as the Manhattan distance $|a_i-c_i|+|b_i-d_i|$ is less than 100.

Tools (Input generator and visualizer)
--------
- Local version: You need a compilation environment of Rust language.
- Web version: This is more powerful than the local version and can display animations.

**Sharing visualization results is not allowed until the end of the contest. **

{sample example}


Story
--------
AtCoder, a big tech company, has many offices.
In order to securely share super-secret information of problem statements for future contests, we decided to set up private lines using quantum cryptography between the offices.
There are several candidates for office pairs that can be connected by private lines, and we want to make sure that all offices are connected by private lines.
The cost of setting up a private line is proportional to the length of the line, but due to physical limitations, it is not always possible to set up a straight line, so we have asked vendors to estimate the exact cost for each candidate.
Since CEO Takahashi is impatient, once he receives the estimate for one candidate, he immediately decides whether to set up that line or not.
Please support Takahashi and help him achieve his goal at a lower cost as possible.

Problem Statement
--------
You are given an undirected graph with $N$ vertices and $M$ edges.
Each vertex is on a two-dimensional plane, and the coordinates of the $i$-th vertex is $(x_i, y_i)$.
The $i$-th edge connects vertices $u_i$ and $v_i$, and we know in advance that its length $l_i$ satisfies $d_i \leq l_i \leq 3 d_i$, where $d_i=\mathrm{round}(\sqrt{(x_{u_i}-x_{v_i})^2+(y_{u_i}-y_{v_i})^2})$ is the Euclidean distance between the endpoints rounded to the nearest integer.

The true edge length $l_i$ will be given one by one in order from $i=0$ to $i=M-1$.
After receiving the length $l_i$ of the $i$-th edge, you have to decide whether to adopt that edge or not before receiving the length $l_{i+1}$ of the next edge.

Let $S$ be the set edges you eventually adopt, then for every vertex pair $(u,v)$, $S$ must contain a path between $u$ and $v$.
Please make decisions so that the total length of the adopted edges is as short as possible.

Input and Output
--------
For all test cases, we fix $N=400$ and $M=1995$.

At the start of the execution, the coordinates of $N$ vertices $(x_0,y_0), \cdots, (x_{N-1},y_{N-1})$ and the endpoints of $M$ edges $(u_0,v_0), \cdots, (u_{M-1},v_{M-1})$ are given from Standard Input in the following format.

~~~
$x_0$ $y_0$
$\vdots$
$x_{N-1}$ $y_{N-1}$
$u_0$ $v_0$
$\vdots$
$u_{M-1}$ $v_{M-1}$
~~~
It is guaranteed to satisfy the following.

- $0\leq x_i,y_i\leq 800$
- $0\leq u_i<v_i\leq N-1$
- The same $(u_i,v_i)$ pair never appears more than once.
- The graph is connected.

Then, repeat the following process $M$ times.

In the $i$-th ($0\leq i\leq M-1$) process, the length $l_i$ of the $i$-th edge is generated uniformly at random from integers between $d_i$ and $3 d_i$, and given to Standard Input in a single line.
After reading $l_i$, output `1` if you adopt the $i$-th edge, or `0` if you don't, in one line to Standard Output.
**Note that the next input is not given until your program outputs 0 or 1. After the output, you have to flush Standard Output.** Otherwise, the submission might be judged as TLE .

Example
-----------------

$i$
Input
Output

Prior information

406 19
347 786
$\vdots$
21 191

$0$

69

1

$1$

89

0

$\vdots$

$M-1$

175

0

Scoring
--------
Let $A$ be the total length of the set of adopted edges,
$B$ be the total length of the optimal set of edges under the condition that the true length $l_i$ of every edge is known in advance (minimum spanning tree).
Then, you will get a score of $\mathrm{round}(10^8\times B/A)$.
When the set of adopted edges does not make the graph connected, your submission will be judged as WA.
Note that if your program terminates abnormally, it may be judged as WA instead of RE.

There are 150 test cases, and the score of a submission is the total score for each test case. If you get a result other than AC for one or more test cases, the score of the submission will be zero. The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest. If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniform random integer between $L$ and $U$, inclusive.

#### Generation of $(x_i,y_i)$
For each $i=0,\cdots,N-1$, we generate $x_i=\mathrm{rand}(0,800)$ and $y_i=\mathrm{rand}(0,800)$.
If the Euclidean distance to the coordinates $(x_j,y_j)$ of an already generated vertex $(j We compute a minimum spanning tree $T$ of $G$, and remove all edges in $T$ from $G$ and insert them to $E$.

Finally, by randomly shuffling the order of edges in $E$, we generate the list of edges $(u_0,v_0),\cdots,(u_{M-1},v_{M-1})$.

#### Generation of $l_i$
Let $d_i=\mathrm{round}(\sqrt{(x_{u_i}-x_{v_i})^2+(y_{u_i}-y_{v_i})^2})$ be the Euclidean distance between the endpoints rounded to the nearest integer.
Then we generate $l_i=\mathrm{rand}(d_i,3 d_i)$.

Tools (Input generator and visualizer)
--------
- Local version: You need a compilation environment of Rust language.
- Web version: This is more powerful than the local version and can display animations.

You are allowed to share output images (png or gif) of the provided visualizer for seed=0 on twitter during the contest. You have to use the specified hashtag and public account. List of shared images.


Story
--------
AtCoder's CEO, Takahashi, loves animals and has a number of pets running free in the AtCoder office.
AtCoder's employees have trouble with the pets interrupting their work, so they have decided to place partitions in the office to create a space where pets cannot come in.
Please create as large a space as possible.

Problem Statement
--------
There are $N$ pets and $M$ people in a room with a floor of $30 \times 30$ squares.
All squares are initially passable, and outside of the $30 \times 30$ squares are impassable.
Let $(x, y)$ be the coordinates of the square in row $x$ from the top ($1\leq x\leq 30$) and column $y$ from the left ($1\leq y\leq 30$).
Repeat the following process for $300$ turns.

First, you choose each person's action from the following three types, and perform each action simultaneously.

- Do nothing and stay in the current position.
- Choose a square adjacent to the current position and make it impassable. You cannot choose a square that contains pets or humans at the start of this turn. You cannot choose a square whose adjacent square contains a pet, either. If you choose a square that is already impassable, nothing happens.
- Move to an adjacent passable square. It is not possible to move to a square that becomes impassable by another person's action in this turn.

After all the people have completed their actions for that turn, each pet moves independently.
Rules for pet movement depend on the type of pet, and some pets may move multiple squares in a single turn.
Details are described later.

Squares containing humans or pets are also passable, and each square can contain any number of humans and pets.

Scoring
--------
At the end of $300$ turn, for each $i=1,\cdots,M$, let $R_i$ be the set of squares reachable from the final position of person $i$ through only passable squares, and $n_i$ be the number of pets whose final position is in $R_i$.
Then, person $i$ obtains satisfaction of $s_i=\frac{|R_i|}{900}\times 2^{-n_i}$.
The score for the test case is $\mathrm{round}\left(10^8\times\frac{1}{M}\sum_{i=1}^M s_i\right)$.

#### Number of test cases
- Provisional test: 100
- System test: 2000. We will publish seeds.txt (md5=27bf0702bbe0265900374c3b6b9846b4, sha256=33973e4ded08e3a607fc2e841e14751ff110ae10154b286e7fd5f766ff86d706) after the contest is over.

The score of a submission is the total scores for each test case.
In the provisional test, if your submission produces illegal output or exceeds the time limit for some test cases, the submission itself will be judged as WA or TLE , and the score of the submission will be zero.
In the system test, if your submission produces illegal output or exceeds the time limit for some test cases, only the score for those test cases will be zero.
Note that if your program terminates abnormally, it may be judged as WA instead of RE.

#### About execution time
Execution time may vary slightly from run to run.
In addition, since system tests simultaneously perform a large number of executions, it has been observed that execution time increases by several percent compared to provisional tests.
For these reasons, submissions that are very close to the time limit may result in TLE in the system test.
Please measure the execution time in your program to terminate the process, or have enough margin in the execution time.

Input and Output
--------
First, the initial position and type of each pet, and the initial position of each person are given from Standard Input in the following format
~~~
$N$
$px_1$ $py_1$ $pt_1$
$\vdots$
$px_N$ $py_N$ $pt_N$
$M$
$hx_1$ $hy_1$
$\vdots$
$hx_M$ $hy_M$
~~~
$N$ is an integer between $10$ and $20$ representing the number of pets.
$(px_i,py_i)$ represents the coordinates of the initial position of the $i$-th pet, and $pt_i$ is an integer between $1$ and $5$ representing the type of the $i$-th pet.
$M$ is an integer between $5$ and $10$ representing the number of humans.
$(hx_i,hy_i)$ represents the coordinates of the initial position of the $i$-th human.
The initial positions of all pets and humans are guaranteed to be distinct.

After reading the above information, repeat the following process $300$ turns.

First, output a string of length $M$ where the $i$-th character represents the action of the $i$th person as follows on a single line to Standard Output.
**After the output, you have to flush Standard Output.** Otherwise, the submission might be judged as TLE .

- `.`: Do nothing and stay in the current position.
- `u`, `d`, `l`, `r`: Let $(x,y)$ be the current position. Make the square $(x-1,y)$, $(x+1,y)$, $(x,y-1)$, or $(x,y+1)$ impassable, respectively.
- `U`, `D`, `L`, `R`: Let $(x,y)$ be the current position. Move to the the square $(x-1,y)$, $(x+1,y)$, $(x,y-1)$, or $(x,y+1)$, respectively.

After the output, $N$ strings are given to Standard Input in a single line, separated by spaces.
The $i$-th string represents movement of the $i$-th pet in that turn.
If the pet does not move, the string is `.`.
If it does move, the string is a sequence of characters `U`, `D`, `L`, and `R` representing the movement of one square up, down, left, and right, respectively.

Show example

Pets Movement Rules
--------
We define a basic move as follows: move to a square chosen at random among the adjacent passable squares. From the condition of the squares that can be made impassable, such squares always exist.

Each pet $i$ performs the following moves depending on $pt_i$, an integer value between $1$ and $5$ representing its type.

1.  Cow: Perform one basic move.
2.  Pig: Perform two basic moves.
3.  Rabbit: Perform three basic moves.
4.  Dog: Move toward a target person as follows. The first turn starts with no target. If it has no target, the target person is in the current position, or there exists no path to the target person, then it selects one person uniformly at random among those reachable from the current position, excluding those in the current position. If there is no such person, reset to no target and perform one basic move. Otherwise, move to an adjacent passable square that shortens the shortest distance to the target person (if there are multiple such squares, choose one of them uniformly at random), and then perform one basic move. If it reaches the destination after the first or the second move, reset to no target.
5.  Cat: Move toward a target square as follows. The first turn starts with no target. If it has no target or there exists no path to the target square, then it selects one square uniformly at random among those reachable from the current position, excluding the current position. If there exists no such square, do nothing. Otherwise, move to an adjacent passable square that shortens the shortest distance to the target square (if there are multiple such squares, choose one of them uniformly at random), and then perform one basic move. If it reaches the destination after the first or the second move, reset to no target.

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniform random integer between $L$ and $U$, inclusive.

We generate the number of pets by $N=\mathrm{rand}(10, 20)$.
The initial position of each pet is chosen uniformly at random from the coordinates that have not been chosen yet.
We generate the type of each pet by $pt_i=\mathrm{rand}(1, 5)$.

We generate the number of humans by $M=\mathrm{rand}(5, 10)$.
The initial position of each human is chosen uniformly at random from the coordinates that have not been chosen yet.

Tools
--------
- Local tester: You need a compilation environment of Rust language.
	- For those who are not familiar with the Rust language environment, we have prepared a pre-compiled binary for Windows. tools_x86_64-pc-windows-gnu.zip
	- The first version contained a bug in the cat's movement, which has been fixed at 130 minutes after the contest started. Please re-download it.
	- We have added more examples in README. If you don't know how to use the tools, please refer to README. Also, as stated in the rules, you are free to share information on how to run the provided tools.
- Web visualizer: By pasting the output generated by the local tester into the Output field, you can display the animation of the execution result.

You are allowed to share output images (png or gif) of the provided visualizer for seed=0 on twitter during the contest. You have to use the specified hashtag and public account. You can only share visualization results and scores for seed=0. Do not share scores for other seeds or mention solutions or discussions. List of shared images.

#### Specification of input/output files used by the tools
Input files for the local tester consist of the prior information (the initial position and type of each pet, and the initial position of each person) followed by a random seed value to generate pet movements.
Since the pet's movement depends on human actions, the input file contains only the random seed value and not specific movements.
The local tester writes outputs from your program directly to the output file.
Your program may output comment lines starting with `#`.
The web version of the visualizer displays the comment lines at the time they are output, which may be useful for debugging and analysis.
Since the judge program ignores all comment lines, you can submit a program that outputs comment lines as is.


Story
--------
A map like in the figure below is given.
Takahashi's home is located in the square with the red circle, and AtCoder's office is located in the square with the blue circle.
He memorizes his commuting route to the office as a string of characters such as DRDR, which means Down, Right, Down, and Right.
Because he is quite forgetful, he sometimes forgets some parts of the string he has memorized.
For example, if he forgets the third character, he will move down, right, and right, and will be lost without reaching the office.
Therefore, he decided to memorize a robust string that would allow him to reach the office with a high probability even if he forgets some parts of the string.
For example, if he memorizes a string DRDRDR, he can reach the office even if he forgets any one of the characters.
Your task is to find a string that will allow Takahashi to reach the office quickly and with a high probability.

DRDR

DRDR

DRDRDR

Problem Statement
--------
You are given a map consisting of $20\times 20$ squares.
The outside of the map is surrounded by walls.
There may also be walls between adjacent squares.
Let $(0,0)$ denote the top-left square, and $(i,j)$ denote the square at the $i$-th row from the top and $j$-th column from the left.
Takahashi's home is located at $(s_i, s_j)$ and AtCoder's office is located at $(t_i, t_j)$.
By representing up, down, left, and right movements as `U`, `D`, `L`, and `R`, respectively, output a commuting route from the home to the office as a string of length less than or equal to $200$.

Let $L$ be the length of the output string.
Starting from the home, Takahashi will do the following action in each $t=1,\cdots,L$ turn.

- With constant probability $p$, he cannot recall the $t$-th character and stays in the current square.
- With the remaining probability $1-p$, he moves one square in the direction represented by the $t$-th character. If there is a wall in that direction, he stays in the current square.

When he gets to the office, he immediately terminate the move.

Scoring
--------
Let $S$ be a random variable defined as $S=401-t$ if he gets to the office after $t$ turns of actions and $S=0$ if he fails to get to the office, and compute its expected value, $E[S]$.
Then, you will get a score of $\mathrm{round}(250000\times E[S])$.
If your output is invalid (the length exceeds 200 or contains characters other than `U`, `D`, `L`, and `R`), it will be judged as WA.

There are 100 test cases, and the score of a submission is the total score for each test case. If you get a result other than AC for one or more test cases, the score of the submission will be zero. The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest. If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Input
--------
Input is given from Standard Input in the following format:

~~~
$s_i$ $s_j$ $t_i$ $t_j$ $p$
$h_{0,0}$ $\cdots$ $h_{0,18}$
$\vdots$
$h_{19,0}$ $\cdots$ $h_{19,18}$
$v_{0,0}$ $\cdots$ $v_{0,19}$
$\vdots$
$v_{18,0}$ $\cdots$ $v_{18,19}$
~~~

The coordinates of the home and the office satisfy $0\leq s_i\leq 4$, $0\leq s_j\leq 4$, $15\leq t_i\leq 19$, and $15\leq t_j\leq 19$.
$p$ is a real number representing the probability of forgetting each character and satisfies $0.1\leq p\leq 0.5$.
$h_{i,0}$ $\cdots$ $h_{i,18}$ is a string of $19$ characters consisting of only $0$ or $1$.
If there is a wall between the squares $(i,j)$ and $(i,j+1)$, then $h_{i,j}=1$, otherwise $h_{i,j}=0$.
$v_{i,0}$ $\cdots$ $v_{i,19}$ is a string of $20$ characters consisting of only $0$ or $1$.
If there is a wall between the squares $(i,j)$ and $(i+1,j)$, then $v_{i,j}=1$, otherwise $v_{i,j}=0$.
It is guaranteed that all squares are reachable from the home.

Output
--------
Output a string that Takahashi memorizes in one line to Standard Output.

Show example

Input Generation
--------

Let $\mathrm{rand}(L,U)$ be a function that generates a uniform random integer between $L$ and $U$, inclusive.

#### Generation of $(s_i, s_j)$, $(t_i, t_j)$, and $p$
We generate $s_i=\mathrm{rand}(0, 4)$, $s_j=\mathrm{rand}(0, 4)$, $t_i=\mathrm{rand}(15, 19)$, $t_j=\mathrm{rand}(15, 19)$, and $p=\mathrm{rand}(10, 50) / 100$.

#### Generation of $h_{i,j}$ and $v_{i,j}$
Let $[k]=\\{0,1,\cdots,k-1\\}$.
Let $G=(V,E)$ be a grid graph such that $V=[20]\times[20]$ and $E=\\{\\{(i,j),(i,j+1)\\}\mid i\in[20],j\in[19]\\}\cup\\{\\{(i,j),(i+1,j)\\}\mid i\in[19],j\in[20]\\}$.
We generate two spanning trees $G_r=(V,E_r)$ $(r=1,2)$ of $G$ by performing the following process twice independently.

1. First, we randomly shuffle the edges $E$ and obtain an ordered edge list $e_0,\cdots,e_{759}$.
2. Starting from $E_r=\emptyset$, for each $e_k=\\{(i,j),(i',j')\\}$ in order from $k=0$ to $k=759$, we insert $e_k$ into $E_r$ if $(i,j)$ and $(i',j')$ are not connected in $G_r$.

Using the obtained two spanning trees, we generate $h$ and $v$ as follows.

- $h_{i,j}=0 \iff \\{(i,j),(i,j+1)\\}\in E_1\cup E_2$
- $v_{i,j}=0 \iff \\{(i,j),(i+1,j)\\}\in E_1\cup E_2$

Tools (Input generator and visualizer)
--------
- Web version: This is more powerful than the local version and can display animations.
- Local version: You need a compilation environment of Rust language.
	- Pre-compiled binary for Windows: If you are not familiar with the Rust language environment, please use this instead.

**Sharing visualization results is not allowed until the end of the contest. **

{sample example}


Story
--------
Takahashi, who loves loop lines, is playing with a toy train.
As shown in the figure below, this toy consists of square tiles containing railroad lines.
By rotating the tiles, he can connect lines and play with toy trains running on the lines.
Because Takahashi has two toy trains, please create two large loop lines as much as possible.

<svg height="100" id="vis" viewBox="-5 -5 100 100" width="100" xmlns="http://www.w3.org/2000/svg">
<rect fill="white" height="100" width="100" x="-5" y="-5"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="0" y2="0"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="0" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="30" y2="30"/>
<line stroke="lightgray" stroke-width="1" x1="30" x2="30" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="60" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="60" x2="60" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="90" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="90" x2="90" y1="0" y2="90"/>
<defs>
<g id="rail1" stroke-width="2">
<line x1="12" x2="12" y1="0" y2="30"/>
<line x1="18" x2="18" y1="0" y2="30"/>
<line x1="12" x2="18" y1="3" y2="3"/>
<line x1="12" x2="18" y1="9" y2="9"/>
<line x1="12" x2="18" y1="15" y2="15"/>
<line x1="12" x2="18" y1="21" y2="21"/>
<line x1="12" x2="18" y1="27" y2="27"/>
</g>
<g fill="none" id="rail2" stroke-width="2">
<path d="M12,0 A12,12 0 0,1 0,12"/>
<path d="M18,0 A18,18 0 0,1 0,18"/>
<line x1="12" x2="18" y1="2" y2="3"/>
<line x1="11" x2="16" y1="5" y2="8"/>
<line x1="8" x2="13" y1="8" y2="13"/>
<line x1="5" x2="8" y1="11" y2="16"/>
<line x1="2" x2="3" y1="12" y2="18"/>
</g>
</defs>
<use href="#rail1" stroke="silver" x="0" y="0"/>
<use href="#rail2" stroke="silver" x="30" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(180,45,15)" x="30" y="0"/>
<use href="#rail2" stroke="silver" x="60" y="0"/>
<use href="#rail2" stroke="silver" x="0" y="30"/>
<use href="#rail2" stroke="silver" transform="rotate(180,15,45)" x="0" y="30"/>
<use href="#rail2" stroke="silver" x="30" y="30"/>
<use href="#rail2" stroke="silver" transform="rotate(180,45,45)" x="30" y="30"/>
<use href="#rail2" stroke="silver" transform="rotate(180,75,45)" x="60" y="30"/>
<use href="#rail2" stroke="silver" transform="rotate(270,15,75)" x="0" y="60"/>
<use href="#rail2" stroke="silver" transform="rotate(90,15,75)" x="0" y="60"/>
<use href="#rail2" stroke="silver" x="30" y="60"/>
<use href="#rail2" stroke="silver" transform="rotate(180,45,75)" x="30" y="60"/>
<use href="#rail2" stroke="silver" x="60" y="60"/>
</svg>

<svg height="100" id="vis" viewBox="-5 -5 100 100" width="100" xmlns="http://www.w3.org/2000/svg">
<rect fill="white" height="100" width="100" x="-5" y="-5"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="0" y2="0"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="0" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="30" y2="30"/>
<line stroke="lightgray" stroke-width="1" x1="30" x2="30" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="60" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="60" x2="60" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="90" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="90" x2="90" y1="0" y2="90"/>
<defs>
<g id="rail1" stroke-width="2">
<line x1="12" x2="12" y1="0" y2="30"/>
<line x1="18" x2="18" y1="0" y2="30"/>
<line x1="12" x2="18" y1="3" y2="3"/>
<line x1="12" x2="18" y1="9" y2="9"/>
<line x1="12" x2="18" y1="15" y2="15"/>
<line x1="12" x2="18" y1="21" y2="21"/>
<line x1="12" x2="18" y1="27" y2="27"/>
</g>
<g fill="none" id="rail2" stroke-width="2">
<path d="M12,0 A12,12 0 0,1 0,12"/>
<path d="M18,0 A18,18 0 0,1 0,18"/>
<line x1="12" x2="18" y1="2" y2="3"/>
<line x1="11" x2="16" y1="5" y2="8"/>
<line x1="8" x2="13" y1="8" y2="13"/>
<line x1="5" x2="8" y1="11" y2="16"/>
<line x1="2" x2="3" y1="12" y2="18"/>
</g>
</defs>
<use href="#rail1" stroke="silver" x="0" y="0"/>
<use href="#rail2" stroke="silver" x="30" y="0"/>
<g>
<use href="#rail2" stroke="brown" transform="rotate(180,45,15)" x="30" y="0"/>
</g>
<g>
<use href="#rail2" stroke="brown" transform="rotate(270,75,15)" x="60" y="0"/>
</g>
<use href="#rail2" stroke="silver" x="0" y="30"/>
<g>
<use href="#rail2" stroke="brown" transform="rotate(180,15,45)" x="0" y="30"/>
</g>
<g>
<use href="#rail2" stroke="brown" x="30" y="30"/>
</g>
<g>
<use href="#rail2" stroke="brown" transform="rotate(180,45,45)" x="30" y="30"/>
</g>
<g>
<use href="#rail2" stroke="brown" x="60" y="30"/>
</g>
<use href="#rail2" stroke="silver" transform="rotate(270,15,75)" x="0" y="60"/>
<g>
<use href="#rail2" stroke="brown" transform="rotate(90,15,75)" x="0" y="60"/>
</g>
<g>
<use href="#rail2" stroke="brown" x="30" y="60"/>
</g>
<use href="#rail2" stroke="silver" transform="rotate(180,45,75)" x="30" y="60"/>
<use href="#rail2" stroke="silver" x="60" y="60"/>
</svg>

Initial State.

After rotating the top-right tile and the middle-right tile.

Problem Statement
--------
You are given tiles containing railroad lines arranged in a 30 x 30 square.
There are 8 types of tiles by distinguishing rotations which are numbered as follows.

<svg height="70" id="vis" viewBox="-5 -5 250 70" width="250" xmlns="http://www.w3.org/2000/svg">
<rect fill="white" height="70" width="250" x="-5" y="-5"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="240" y1="0" y2="0"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="0" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="240" y1="30" y2="30"/>
<line stroke="lightgray" stroke-width="1" x1="30" x2="30" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="240" y1="60" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="60" x2="60" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="90" x2="90" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="120" x2="120" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="150" x2="150" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="180" x2="180" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="210" x2="210" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="240" x2="240" y1="0" y2="60"/>
<text font-size="22" text-anchor="middle" x="15" y="55">
0
</text>
<text font-size="22" text-anchor="middle" x="45" y="55">
1
</text>
<text font-size="22" text-anchor="middle" x="75" y="55">
2
</text>
<text font-size="22" text-anchor="middle" x="105" y="55">
3
</text>
<text font-size="22" text-anchor="middle" x="135" y="55">
4
</text>
<text font-size="22" text-anchor="middle" x="165" y="55">
5
</text>
<text font-size="22" text-anchor="middle" x="195" y="55">
6
</text>
<text font-size="22" text-anchor="middle" x="225" y="55">
7
</text>
<defs>
<g id="rail1" stroke-width="2">
<line x1="12" x2="12" y1="0" y2="30"/>
<line x1="18" x2="18" y1="0" y2="30"/>
<line x1="12" x2="18" y1="3" y2="3"/>
<line x1="12" x2="18" y1="9" y2="9"/>
<line x1="12" x2="18" y1="15" y2="15"/>
<line x1="12" x2="18" y1="21" y2="21"/>
<line x1="12" x2="18" y1="27" y2="27"/>
</g>
<g fill="none" id="rail2" stroke-width="2">
<path d="M12,0 A12,12 0 0,1 0,12"/>
<path d="M18,0 A18,18 0 0,1 0,18"/>
<line x1="12" x2="18" y1="2" y2="3"/>
<line x1="11" x2="16" y1="5" y2="8"/>
<line x1="8" x2="13" y1="8" y2="13"/>
<line x1="5" x2="8" y1="11" y2="16"/>
<line x1="2" x2="3" y1="12" y2="18"/>
</g>
</defs>
<use href="#rail2" stroke="silver" x="0" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(270,45,15)" x="30" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(180,75,15)" x="60" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(90,105,15)" x="90" y="0"/>
<use href="#rail2" stroke="silver" x="120" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(180,135,15)" x="120" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(270,165,15)" x="150" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(90,165,15)" x="150" y="0"/>
<use href="#rail1" stroke="silver" transform="rotate(90,195,15)" x="180" y="0"/>
<use href="#rail1" stroke="silver" x="210" y="0"/>
</svg>

Tiles 0 to 3 contain one curved line, tiles 4 and 5 contain two curved lines, and tiles 6 and 7 contain one straight line.
Each tile can be rotated every 90 degrees.
By rotating a tile 90 degrees counterclockwise, the tile will become as follows.

<svg height="70" id="vis" viewBox="-5 -5 250 70" width="250" xmlns="http://www.w3.org/2000/svg">
<rect fill="white" height="70" width="250" x="-5" y="-5"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="240" y1="0" y2="0"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="0" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="240" y1="30" y2="30"/>
<line stroke="lightgray" stroke-width="1" x1="30" x2="30" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="240" y1="60" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="60" x2="60" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="90" x2="90" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="120" x2="120" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="150" x2="150" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="180" x2="180" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="210" x2="210" y1="0" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="240" x2="240" y1="0" y2="60"/>
<text font-size="22" text-anchor="middle" x="15" y="55">
1
</text>
<text font-size="22" text-anchor="middle" x="45" y="55">
2
</text>
<text font-size="22" text-anchor="middle" x="75" y="55">
3
</text>
<text font-size="22" text-anchor="middle" x="105" y="55">
0
</text>
<text font-size="22" text-anchor="middle" x="135" y="55">
5
</text>
<text font-size="22" text-anchor="middle" x="165" y="55">
4
</text>
<text font-size="22" text-anchor="middle" x="195" y="55">
7
</text>
<text font-size="22" text-anchor="middle" x="225" y="55">
6
</text>
<defs>
<g id="rail1" stroke-width="2">
<line x1="12" x2="12" y1="0" y2="30"/>
<line x1="18" x2="18" y1="0" y2="30"/>
<line x1="12" x2="18" y1="3" y2="3"/>
<line x1="12" x2="18" y1="9" y2="9"/>
<line x1="12" x2="18" y1="15" y2="15"/>
<line x1="12" x2="18" y1="21" y2="21"/>
<line x1="12" x2="18" y1="27" y2="27"/>
</g>
<g fill="none" id="rail2" stroke-width="2">
<path d="M12,0 A12,12 0 0,1 0,12"/>
<path d="M18,0 A18,18 0 0,1 0,18"/>
<line x1="12" x2="18" y1="2" y2="3"/>
<line x1="11" x2="16" y1="5" y2="8"/>
<line x1="8" x2="13" y1="8" y2="13"/>
<line x1="5" x2="8" y1="11" y2="16"/>
<line x1="2" x2="3" y1="12" y2="18"/>
</g>
</defs>
<use href="#rail2" stroke="silver" transform="rotate(270,15,15)" x="0" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(180,45,15)" x="30" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(90,75,15)" x="60" y="0"/>
<use href="#rail2" stroke="silver" x="90" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(270,135,15)" x="120" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(90,135,15)" x="120" y="0"/>
<use href="#rail2" stroke="silver" x="150" y="0"/>
<use href="#rail2" stroke="silver" transform="rotate(180,165,15)" x="150" y="0"/>
<use href="#rail1" stroke="silver" x="180" y="0"/>
<use href="#rail1" stroke="silver" transform="rotate(90,225,15)" x="210" y="0"/>
</svg>

Since there are no branches on the lines, each line is part of a path or cycle.
A set of lines forming a cycle is called a "loop line," and its length is defined as the number of times to move from a tile to its adjacent tile in a round trip along the loop line.
For example, the loop line below consists of 7 tiles, but its length is 8 because it passes through the center tile twice.

<svg height="100" id="vis" viewBox="-5 -5 100 100" width="100" xmlns="http://www.w3.org/2000/svg">
<rect fill="white" height="100" width="100" x="-5" y="-5"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="0" y2="0"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="0" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="30" y2="30"/>
<line stroke="lightgray" stroke-width="1" x1="30" x2="30" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="60" y2="60"/>
<line stroke="lightgray" stroke-width="1" x1="60" x2="60" y1="0" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="0" x2="90" y1="90" y2="90"/>
<line stroke="lightgray" stroke-width="1" x1="90" x2="90" y1="0" y2="90"/>
<defs>
<g id="rail1" stroke-width="2">
<line x1="12" x2="12" y1="0" y2="30"/>
<line x1="18" x2="18" y1="0" y2="30"/>
<line x1="12" x2="18" y1="3" y2="3"/>
<line x1="12" x2="18" y1="9" y2="9"/>
<line x1="12" x2="18" y1="15" y2="15"/>
<line x1="12" x2="18" y1="21" y2="21"/>
<line x1="12" x2="18" y1="27" y2="27"/>
</g>
<g fill="none" id="rail2" stroke-width="2">
<path d="M12,0 A12,12 0 0,1 0,12"/>
<path d="M18,0 A18,18 0 0,1 0,18"/>
<line x1="12" x2="18" y1="2" y2="3"/>
<line x1="11" x2="16" y1="5" y2="8"/>
<line x1="8" x2="13" y1="8" y2="13"/>
<line x1="5" x2="8" y1="11" y2="16"/>
<line x1="2" x2="3" y1="12" y2="18"/>
</g>
</defs>
<use href="#rail1" stroke="silver" x="0" y="0"/>
<use href="#rail2" stroke="silver" x="30" y="0"/>
<g>
<use href="#rail2" stroke="brown" transform="rotate(180,45,15)" x="30" y="0"/>
</g>
<g>
<use href="#rail2" stroke="brown" transform="rotate(270,75,15)" x="60" y="0"/>
</g>
<use href="#rail2" stroke="silver" x="0" y="30"/>
<g>
<use href="#rail2" stroke="brown" transform="rotate(180,15,45)" x="0" y="30"/>
</g>
<g>
<use href="#rail2" stroke="brown" x="30" y="30"/>
</g>
<g>
<use href="#rail2" stroke="brown" transform="rotate(180,45,45)" x="30" y="30"/>
</g>
<g>
<use href="#rail2" stroke="brown" x="60" y="30"/>
</g>
<use href="#rail2" stroke="silver" transform="rotate(270,15,75)" x="0" y="60"/>
<g>
<use href="#rail2" stroke="brown" transform="rotate(90,15,75)" x="0" y="60"/>
</g>
<g>
<use href="#rail2" stroke="brown" x="30" y="60"/>
</g>
<use href="#rail2" stroke="silver" transform="rotate(180,45,75)" x="30" y="60"/>
<use href="#rail2" stroke="silver" x="60" y="60"/>
</svg>

Your task is to determine the number of times to rotate each tile.

Scoring
--------
Let $L_1$ be the length of the longest loop line obtained by rotating the tiles according to the output, and $L_2$ be the length of the second longest one ($L_1=L_2$ if there is more than one longest one).
Then, you will get a score of $L_1\times L_2$.
If the number of loop lines is less than or equal to $1$, the score for that test case is $0$.

There are 100 test cases, and the score of a submission is the total score for each test case. If you get a result other than AC for one or more test cases, the score of the submission will be zero. The highest score obtained during the contest time will determine the final ranking, and there will be no system test after the contest. If more than one participant gets the same score, the ranking will be determined by the submission time of the submission that received that score.

Hints on how to compute the length of a loop line.

Pseudo code has been updated.

You can compute the length of a loop line, for example, as follows.
Let `tiles` be a two-dimensional array containing the tile states.
By numbering the directions 0, 1, 2, 3 in order of left, up, right, and down, the change in coordinates is represented by the arrays `di = [0, -1, 0, 1]` and `dj = [-1, 0, 1, 0]`.
When a train enters a tile of state `t` from its adjacent tile in direction `d`, let `to[t][d]` be the direction to the next tile, or `-1` if the train cannot enter from such a direction, then we obtain the following two-dimensional array.
```
to = [
	[1, 0, -1, -1],
	[3, -1, -1, 0],
	[-1, -1, 3, 2],
	[-1, 2, 1, -1],
	[1, 0, 3, 2],
	[3, 2, 1, 0],
	[2, -1, 0, -1],
	[-1, 3, -1, 1],
];
```
When a train enters tile at position `(i, j)` from its adjacent tile in direction `d`, you can update these variables as follows.

```
d2 = to[tiles[i][j]][d]; // Direction to the next tile
if (d2 == -1) return 0; // The line is broken.
i += di[d2];
j += dj[d2];
if (i < 0 || i >= 30 || j < 0 || j >= 30) return 0; // The line is broken.
d = (d2 + 2) % 4; // Direction to the previous tile.
```
After repeating this process until the train returns to its initial position and direction (note that it may pass through the same tile twice), the number of iterations is the length of the loop line.
```
// Suppose that a train enters a tile (si, sj) from direction sd.
i = si;
j = sj;
d = sd;
length = 0;
loop {
	d2 = to[tiles[i][j]][d];
	if (d2 == -1) return 0;
	i += di[d2];
	j += dj[d2];
	if (i < 0 || i >= 30 || j < 0 || j >= 30) return 0;
	d = (d2 + 2) % 4;
	length += 1;
	if (i == si && j == sj && d == sd) return length;
}
```

Input
--------
Input is given from Standard Input in the following format:

~~~
$t_{0,0}$ $\cdots$ $t_{0,29}$
$\vdots$
$t_{29,0}$ $\cdots$ $t_{29,29}$
~~~

Each $t_{i,0}\cdots t_{i,29}$ is a string of $30$ characters.
Let $(i,j)$ denote the $i$-th $(0\leq i\leq 29)$ tile from the top and $j$-th $(0\leq j\leq 29)$ tile from the left.
Then, $t_{i,j}$ is an integer between $0$ and $7$ representing the state of the tile $(i, j)$.

Output
--------
Let $r_{i,j}$ ($0\leq r_{i,j}\leq 3$) be the number of times the tile $(i,j)$ is rotated 90 degrees counterclockwise.
Output a string of length $900$ such that the $30i+j$-th character is $r_{i,j}$ in one line to Standard Output.

Show example

Input Generation
--------
Let $\mathrm{rand}(L,U)$ be a function that generates a uniform random integer between $L$ and $U$, inclusive.

Each $t_{i,j}$ is independently generated as follows.

- With probability 25%, $t_{i,j}=\mathrm{rand}(0, 3)$.
- With probability 50%, $t_{i,j}=\mathrm{rand}(4, 5)$.
- With probability 25%, $t_{i,j}=\mathrm{rand}(6, 7)$.

Tools (Input generator and visualizer)
--------
- Web version: This is more powerful than the local version and can display animations.
- Local version: You need a compilation environment of Rust language.
	- Pre-compiled binary for Windows: If you are not familiar with the Rust language environment, please use this instead.

**Sharing visualization results is not allowed until the end of the contest. **

{sample example}