{"raw_statement":[{"iden":"statement","content":"Vitaly works at the warehouse. The warehouse can be represented as a grid of n × m cells, each of which either is free or is occupied by a container. From every free cell it's possible to reach every other free cell by moving only through the cells sharing a side. Besides that, there are two robots in the warehouse. The robots are located in different free cells.\n\nVitaly wants to swap the robots. Robots can move only through free cells sharing a side, moreover, they can't be in the same cell at the same time or move through each other. Find out if the swap can be done.\n\nThe first line contains two positive integers n and m (2 ≤ n·m ≤ 200000) — the sizes of the warehouse.\n\nEach of the next n lines contains m characters. The j-th character of the i-th line is «_._» if the corresponding cell is free, «_#_» if there is a container on it, «_1_» if it's occupied by the first robot, and «_2_» if it's occupied by the second robot. The characters «_1_» and «_2_» appear exactly once in these lines.\n\nOutput «_YES_» (without quotes) if the robots can be swapped, and «_NO_» (without quotes) if that can't be done.\n\n"},{"iden":"input","content":"The first line contains two positive integers n and m (2 ≤ n·m ≤ 200000) — the sizes of the warehouse.Each of the next n lines contains m characters. The j-th character of the i-th line is «_._» if the corresponding cell is free, «_#_» if there is a container on it, «_1_» if it's occupied by the first robot, and «_2_» if it's occupied by the second robot. The characters «_1_» and «_2_» appear exactly once in these lines."},{"iden":"output","content":"Output «_YES_» (without quotes) if the robots can be swapped, and «_NO_» (without quotes) if that can't be done."},{"iden":"examples","content":"Input5 3####1##.##2####OutputNOInput3 5#...##1.2######OutputYES"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ with $ 2 \\leq n \\cdot m \\leq 200000 $.  \nLet $ G = (V, E) $ be a grid graph of size $ n \\times m $, where each cell $ (i,j) $ is a vertex, and edges connect horizontally/vertically adjacent free cells (i.e., cells marked `'.'`, `'1'`, or `'2'`).  \nLet $ r_1, r_2 \\in V $ be the distinct positions of the two robots (marked `'1'` and `'2'`).  \n\n**Constraints**  \n1. Each cell is either:  \n   - Free (`'.'`),  \n   - Occupied by a container (`'#'`),  \n   - Occupied by robot 1 (`'1'`),  \n   - Occupied by robot 2 (`'2'`).  \n2. `'1'` and `'2'` appear exactly once.  \n3. All free cells (including $ r_1 $ and $ r_2 $) form a single connected component under 4-directional adjacency.  \n\n**Objective**  \nDetermine whether there exists a finite sequence of valid moves such that:  \n- Each move consists of one robot moving to an adjacent free cell.  \n- Robots never occupy the same cell simultaneously.  \n- Robots never pass through each other (i.e., no swap of positions in a single step).  \n- The final configuration has robot 1 at $ r_2 $ and robot 2 at $ r_1 $.  \n\nOutput `YES` if such a sequence exists, `NO` otherwise.","simple_statement":"You are given a grid with free cells, containers, and two robots (labeled '1' and '2').  \nRobots can move to adjacent free cells (up, down, left, right) but cannot occupy the same cell or pass through each other.  \nCan the two robots swap positions?  \nOutput \"YES\" if possible, \"NO\" otherwise.","has_page_source":false}