Art class

No attempts yetTime limit5sMemory limit256 MB

Problem

An art history exam is coming, and you have been paying more attention to informatics than to art class. You want to write a program that can take the exam in your place.

The exam presents several paintings. Each painting belongs to one of four styles with distinct visual traits, numbered 11, 22, 33, and 44.

Style 11 is neoplastic modern art. The canvas is divided by straight black lines into solid rectangles of red, blue, yellow, white, or black. Color is nearly uniform inside each block, and black lines mark the boundaries.

Style 22 is impressionist landscape painting. Trees, grass, sky, and paths appear, with plenty of green and blue. Brushstrokes make nearby pixels differ a little even inside the same region.

Style 33 is expressionist action painting, made by dripping or splattering paint. Colors mix chaotically and the surface is very grainy. Green is not the main color.

Style 44 is color field painting. Broad bands of similar color are spread across the canvas. Edges are soft, black grid lines are almost absent, and variation inside a band is small.

Given a digital image of a painting, decide which of the four styles it belongs to. Each image belongs to exactly one style.

The image is an H×WH \times W grid of pixels. Rows are numbered 0,,H10, \ldots, H-1 from top to bottom, and columns are numbered 0,,W10, \ldots, W-1 from left to right.

Pixels are given by three two-dimensional arrays RR, GG, and BB, the red, green, and blue intensities. Each intensity is an integer from 00 (none of that color) to 255255 (the strongest amount).

Input

The first line contains HH and WW. (100H,W500100 \le H, W \le 500)

The next HH lines contain the values of R[i][j]R[i][j]. The next HH lines contain the values of G[i][j]G[i][j]. The next HH lines contain the values of B[i][j]B[i][j]. Each of those lines has WW integers separated by spaces.

Output

Print the style number of the given painting. It must be one of 11, 22, 33, or 44.

Hint

Styles 11 and 44 have large smooth color regions, while styles 22 and 33 are grainy. Style 11 has clear black boundary lines, and style 44 does not. Style 22 is green-dominant, and style 33 is not.