{"problem":{"name":"ABC Puzzle","description":{"content":"You are given an integer $N$ and strings $R$ and $C$ of length $N$ consisting of `A`, `B`, and `C`. Solve the following problem. There is a $N \\times N$ grid. All cells are initially empty.   You can ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc326_d"},"statements":[{"statement_type":"Markdown","content":"You are given an integer $N$ and strings $R$ and $C$ of length $N$ consisting of `A`, `B`, and `C`. Solve the following problem.\nThere is a $N \\times N$ grid. All cells are initially empty.  \nYou can write at most one character from `A`, `B`, and `C` in each cell. (You can also leave the cell empty.)\nDetermine if it is possible to satisfy all of the following conditions, and if it is possible, print one way to do so.\n\n*   Each row and each column contain exactly one `A`, one `B`, and one `C`.\n*   The leftmost character written in the $i$\\-th row matches the $i$\\-th character of $R$.\n*   The topmost character written in the $i$\\-th column matches the $i$\\-th character of $C$.\n\n## Constraints\n\n*   $N$ is an integer between $3$ and $5$, inclusive.\n*   $R$ and $C$ are strings of length $N$ consisting of `A`, `B`, and `C`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$R$\n$C$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc326_d","tags":[],"sample_group":[["5\nABCBC\nACAAB","Yes\nAC..B\n.BA.C\nC.BA.\nBA.C.\n..CBA\n\nThe grid in the output example satisfies all the following conditions, so it will be treated as correct.\n\n*   Each row contains exactly one `A`, one `B`, and one `C`.\n*   Each column contains exactly one `A`, one `B`, and one `C`.\n*   The leftmost characters written in the rows are `A`, `B`, `C`, `B`, `C` from top to bottom.\n*   The topmost characters written in the columns are `A`, `C`, `A`, `A`, `B` from left to right."],["3\nAAA\nBBB","No\n\nFor this input, there is no way to fill the grid to satisfy the conditions."]],"created_at":"2026-03-03 11:01:14"}}