{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"In a modernized warehouse, robots are used to fetch the goods. Careful planning is needed to ensure that the robots reach their destinations without crashing into each other. Of course, all warehouses are rectangular, and all robots occupy a circular floor space with a diameter of 1 meter. Assume there are N robots, numbered from 1 through N. You will get to know the position and orientation of each robot, and all the instructions, which are carefully (and mindlessly) followed by the robots. Instructions are processed in the order they come. No two robots move simultaneously; a robot always completes its move before the next one starts moving.\r\u003cbr\u003eA robot crashes with a wall if it attempts to move outside the area of the warehouse, and two robots crash with each other if they ever try to occupy the same spot."}},{"title":"Input","value":{"format":"HTML","content":"The first line of input is K, the number of test cases. Each test case starts with one line consisting of two integers, 1 \u0026lt;\u003d A, B \u0026lt;\u003d 100, giving the size of the warehouse in meters. A is the length in the EW-direction, and B in the NS-direction.\r\u003cbr\u003eThe second line contains two integers, 1 \u0026lt;\u003d N, M \u0026lt;\u003d 100, denoting the numbers of robots and instructions respectively.\r\u003cbr\u003eThen follow N lines with two integers, 1 \u0026lt;\u003d Xi \u0026lt;\u003d A, 1 \u0026lt;\u003d Yi \u0026lt;\u003d B and one letter (N, S, E or W), giving the starting position and direction of each robot, in order from 1 through N. No two robots start at the same position.\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/5c7adf6dcd1e44166dc55094bc35f881?v\u003d1714803420\"\u003e\r\u003cbr\u003eFigure 1: The starting positions of the robots in the sample warehouse\u003c/center\u003e\r\u003cbr\u003eFinally there are M lines, giving the instructions in sequential order.\r\u003cbr\u003eAn instruction has the following format:\r\u003cbr\u003e\u0026lt; robot #\u0026gt; \u0026lt; action\u0026gt; \u0026lt; repeat\u0026gt;\r\u003cbr\u003eWhere \u003caction\u003e is one of\r\u003cbr\u003e\u003cul\u003e\u003cli\u003eL: turn left 90 degrees,\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eR: turn right 90 degrees, or\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eF: move forward one meter,\u003c/li\u003e\u003c/ul\u003e\r\u003cbr\u003eand 1 \u0026lt;\u003d \u0026lt; repeat\u0026gt; \u0026lt;\u003d 100 is the number of times the robot should perform this single move.\u003c/action\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output one line for each test case:\r\u003cbr\u003e\u003cul\u003e\u003cli\u003eRobot i crashes into the wall, if robot i crashes into a wall. (A robot crashes into a wall if Xi \u003d 0, Xi \u003d A + 1, Yi \u003d 0 or Yi \u003d B + 1.)\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eRobot i crashes into robot j, if robots i and j crash, and i is the moving robot.\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eOK, if no crashing occurs.\u003c/li\u003e\u003c/ul\u003e\r\u003cbr\u003eOnly the first crash is to be reported."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n5 4\r\n2 2\r\n1 1 E\r\n5 4 W\r\n1 F 7\r\n2 F 7\r\n5 4\r\n2 4\r\n1 1 E\r\n5 4 W\r\n1 F 3\r\n2 F 1\r\n1 L 1\r\n1 F 3\r\n5 4\r\n2 2\r\n1 1 E\r\n5 4 W\r\n1 L 96\r\n1 F 2\r\n5 4\r\n2 3\r\n1 1 E\r\n5 4 W\r\n1 F 4\r\n1 L 1\r\n1 F 20\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eRobot 1 crashes into the wall\r\nRobot 1 crashes into robot 2\r\nOK\r\nRobot 1 crashes into robot 2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}