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 1, 2, 3, and 4.
Style 1 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 2 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 3 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 4 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×W grid of pixels. Rows are numbered 0,…,H−1 from top to bottom, and columns are numbered 0,…,W−1 from left to right.
Pixels are given by three two-dimensional arrays R, G, and B, the red, green, and blue intensities. Each intensity is an integer from 0 (none of that color) to 255 (the strongest amount).
The first line contains H and W. (100≤H,W≤500)
The next H lines contain the values of R[i][j]. The next H lines contain the values of G[i][j]. The next H lines contain the values of B[i][j]. Each of those lines has W integers separated by spaces.
Print the style number of the given painting. It must be one of 1, 2, 3, or 4.
Styles 1 and 4 have large smooth color regions, while styles 2 and 3 are grainy. Style 1 has clear black boundary lines, and style 4 does not. Style 2 is green-dominant, and style 3 is not.