Machine Learning is a field derived from the AI, and obviously part of CS, the mission of this field is to develop techniques that let the computers learn.
Pancho Coco Rene Lopez de La Quintana Roo, is our mexican friend who drives a 3D building machine, but he's tired of his job and while we were eating some tacos with him, he told us "help me to automatize my Rosita"(3D Building Machine), since we are good friends we will help Pancho in this task.
We'll apply some algorithms to supply Rosita the best way to work.
The machine works in a building place, what we will consider as a matrix of N x M elements, and in each element a prism with a square base and variable height is placed. In order to do this we have two restrictions given by the architect Gonzales:
Gonzales conditions:
Given the set of Gonzales conditions, we must find an algorithm which can fulfill at least the 75% of the restrictions, assigning height values to each element of the matrix. The allowed heights are between 1 and K , see the next example to understand better:
We have a matrix of N=2 and M=5 .
INNN
IIIII
NINI
The first line show us that the first row of the matrix has four restrictions
The heigth of prism in the cell (1,1) must be equal to the heigth of the prism in the cell (1,2)
The heigth of prism in the cell (1,2) must be distinct to the heigth of the prism in the cell (1,3)
The heigth of prism in the cell (1,3) must be distinct to the heigth of the prism in the cell (1,4)
The heigth of prism in the cell (1,4) must be distinct to the heigth of the prism in the cell (1,5)
The second line show us the restrictions between elements of row 1 and 2. Therefore, there are 5 restrictions between rows 1 and 2:
The heigth of prism in the cell (1,1) must be equal to the heigth of the prism in the cell (2,1)
The heigth of prism in the cell (1,2) must be equal to the heigth of the prism in the cell (2,2)
The heigth of prism in the cell (1,3) must be equal to the heigth of the prism in the cell (2,3)
The heigth of prism in the cell (1,4) must be equal to the heigth of the prism in the cell (2,4)
The heigth of prism in the cell (1,5) must be equal to the heigth of the prism in the cell (2,5)
The third line show us the restrictions in the second row of the matrix, with the same procedure that was applied in the first row.
Input
The first line contains three integer numbers N , M and K , the number of rows, the number of columns and the maximum heigth allowed, respectively.
The next 2∗N−1 lines, describres the restrictions, that lines contains M−1,M,M−1,M,...,M−1 characters each one. The characters could be 'I' if must be equal or 'N' if must be distinct.
Constraint: 1≤N∗M≤106
Output
The output will have a word, because Pancho is mexican the answers will be in spanish.
Print "Si" if we will be able to accomplish at least 75% of the restrictions with this way of work, otherwise print "No".
So..for the sample test there is a valid solution
4 4 2 1 3
4 4 2 1 3
The 4 restrictions of the first line are fulfill, the 5 of the second one and 1 of the third one. The heights are between 1 and 4. So 10 of 13 restrictions are being fulfilled, and that is at least 75% of the restrictions.