#Lutece1311. Excited Table
Excited Table
Migrated from Lutece 1311 Excited Table
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There is a table with legs. Because of the foolishness of the designer, the table may be unstable.
A leg can be describe as three integers , while is its position on the tabletop and the leg is perpendicular to the tabletop with length .
We define a direction of the table is stable if and only if it exists that three or more legs touch the floor and they are not on one plane, and the table can't be upside down.
A table is stable if and only if it has exactly one stable direction.
Because the tabletop is compact enough, the collision between the tabletop and the floor can be neglected.
In addition, the thickness of legs also should be neglected.
You should determine whether the table is stable.
Input
The first line contains one integer .
Then lines follow, each with three integers .
It is guaranteed that no two legs is on the same position.
Output
If the table is stable, print STABLE
; otherwise, print UNSTABLE
.
Samples
4
1 1 1
-1 -1 1
-1 1 1
1 -1 1
STABLE
4
1 1 2
-1 -1 1
-1 1 1
1 -1 1
UNSTABLE
Note
A stable direction of the table in sample 2.
Resources
The 14th UESTC Programming Contest Final