{"raw_statement":[{"iden":"statement","content":"The university of Algoland is located in a single huge building. It is great. It is the best building in the world. It only uses the best angles: the right angle! But the building is so huge that it is also very confusing to new students, because it is very easy to get lost.\n\nThe rector of Algoland's university, a former professor in physics, had a great idea to prevent students from getting lost in the future: He bought an incredibly strong magnet with the intention of placing it somewhere inside the building and using it as an emergency meeting point. On the first day of the semester, every student gets a free compass. With that compass the student can always tell the direction towards the magnet (the magnet is so strong that it completely dominates the earth's magnetic field). If a student gets lost, she can follow the following simple procedure to get to the emergency meeting point at the magnet's location: \n\nIn the corner case where you want to walk parallel to a wall at the exact coordinate of a wall, you are not stopped by the wall. We assume here that you are infinitesimally small (which is true in proportion to the size of the building).\n\nThe rector now wants your help to place the magnet inside the building in such a way that every student can reach it (following the procedure above) no matter where inside the building the student gets lost. Actually, you just have to decide if this is possible or not.\n\nThe first line contains an integer N, the number of points, 4 ≤ N ≤ 103.\n\nEach of the following N lines contains two coordinates x and y (0 ≤ x ≤ 103 and 0 ≤ y ≤ 103). Each line describes a corner point of the single wall that delimits the inside from the outside of the building. The points are given in clockwise order and all the angles are guaranteed to be 90 degrees.\n\nPrint a single line containing a single word: either _SAFETY_ if it is possible to place the magnet such that one is always able to find it, or _DANGER_ otherwise.\n\n"},{"iden":"input","content":"The first line contains an integer N, the number of points, 4 ≤ N ≤ 103.Each of the following N lines contains two coordinates x and y (0 ≤ x ≤ 103 and 0 ≤ y ≤ 103). Each line describes a corner point of the single wall that delimits the inside from the outside of the building. The points are given in clockwise order and all the angles are guaranteed to be 90 degrees."},{"iden":"output","content":"Print a single line containing a single word: either _SAFETY_ if it is possible to place the magnet such that one is always able to find it, or _DANGER_ otherwise."},{"iden":"examples","content":"Input121 01 32 32 13 13 24 24 15 15 36 36 0OutputSAFETYInput120 45 45 02 02 23 23 14 14 31 31 10 1OutputDANGERInput146 46 03 03 12 12 01 01 24 24 15 15 31 31 4OutputSAFETY"},{"iden":"note","content":"  "}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ P = (p_1, p_2, \\dots, p_N) $ be a sequence of $ N $ points in $ \\mathbb{R}^2 $, given in clockwise order, representing the corners of a rectilinear polygon (all internal angles are $ 90^\\circ $).\n\n**Constraints**  \n1. $ 4 \\leq N \\leq 10^3 $  \n2. $ 0 \\leq x_i, y_i \\leq 10^3 $ for all $ i \\in \\{1, \\dots, N\\} $  \n3. The polygon is simple (non-self-intersecting) and axis-aligned (edges are horizontal or vertical).  \n\n**Objective**  \nDetermine whether there exists a point $ m \\in \\text{int}(P) $ (interior of the polygon) such that, for every point $ s \\in \\text{int}(P) $, the axis-aligned path from $ s $ to $ m $ (moving only north, south, east, or west, without crossing the boundary) exists.  \n\nThis is equivalent to checking whether the polygon is **rectilinearly convex** (i.e., the intersection of the polygon with any horizontal or vertical line is connected).  \n\n**Output**  \n- Print **SAFETY** if such a point $ m $ exists.  \n- Print **DANGER** otherwise.","simple_statement":"Given a polygon with only right angles and vertices in clockwise order, determine if there exists a point inside it such that, from every point in the polygon, you can reach it by moving only north, south, east, or west without crossing any wall. Print SAFETY if possible, DANGER otherwise.","has_page_source":false}