In a robot drawing contest, a program made of the following two instructions draws one picture. The robot starts at the picture start point.
L Xrel Yrel draws a line segment from the current position to the point at the given relative offset. The robot moves to the end of that segment.M Xrel Yrel moves the current position by the given relative offset without drawing anything.An L instruction with the relative offset (0,0) has length zero and draws nothing.
Contest submissions are judged by machine. A problem with more than one correct answer needs a separate program, a validator, that compares the submitted result with the answer prepared by the judges. Your task is to write the validator for the drawing problem above.
Two pictures are the same when the visible lines are the same. The instructions may differ. One segment may be drawn as several shorter segments, and the same place may be drawn over many times. Take the set of points that each picture covers. The two pictures are the same if and only if some translation makes the first set equal to the second set. A picture at a different scale or with a different rotation is therefore a different picture. Two pictures that draw no segment at all are the same.
The input holds several test cases, at most 20 of them. Each test case holds two pictures.
Each picture starts with a line holding the number of instructions N (1≤N≤5000). The next N lines hold one instruction each. An instruction is one uppercase letter, one space, the integer Xi, one space, and the integer Yi (∣Xi∣≤1000, ∣Yi∣≤1000). The letter is L or M.
One empty line follows each test case, and the empty line after the last test case may be missing. No absolute coordinate is further than 30000 from the picture start point in any direction.
For each test case, print one line. Print YES if the two pictures are the same and NO if they differ.