SRM 574 DIV 1 Medium - PolygonTraversal: Accepted