Evil Jeometry

Given a binary image (one that contains only 0 and 1) with width of W and height of H your task is to describe what is in the image. There are 4 types of shapes in the image: line, equilateral triangle, square and regular pentagon. They can have any size and can be rotated.


The first line of the input containts two integer numbers: H and W.
The following H lines contain W charaters from set {0, 1} witout spaces. The lines are separated by a newline character.


Your program should output the description of the image:
2 number_of_lines
3 number_of_triangles
4 number_of_squares
5 number_of_pentagons


  • 512 <= H <= 1024
  • 512 <= W <= 1024
  • Side of each figure > 70 (euclidian length).
  • The figures don't overlap and they don't touch the sides of the image.
  • It is impossible to draw a perfect line. Thus, the edges of the shapes are usually not straight.
  • The shapes are solid (there are no zeroes inside them)


>>Link to Input<<
2 0
3 1
4 1
5 1

Sponsors Gold