Glue!
InterviewTime limit2sMemory limit1024 MB
Given a grid of piece labels, check that every label covers exactly k cells and that each piece is connected through shared sides.
Problem
In the basic-level problem "Cut!" of a previous online olympiad, contestants had to cut a sheet of graph paper. The sheet could only be cut along the grid lines, and each resulting piece had to consist of exactly cells of the original sheet.
In this problem, you solve the jury's task: determine whether the team cut the sheet correctly.
Input
The first line contains two integers and (), the height and width of the sheet in cells. The second line contains (). It is guaranteed that is divisible by .
Each of the next lines contains integers. Each integer is the number of the piece that the team assigned to that cell. Pieces are numbered with positive integers starting from 1.
Output
If the team cut the sheet correctly, print OK. Otherwise, print Wrong answer.