#P8090. Herdle Puzzle Scoring

    ID: 21273 Type: Default 1000ms 256MiB

Herdle Puzzle Scoring

Herdle Puzzle Scoring

The cows have invented a new puzzle game called Herdle that has taken the bovine world by storm. In Herdle, a new puzzle is released daily. The game is played on a \(3 \times 3\) grid, representing a section of a farm field. Each cell of the grid is occupied by a cow of a specific breed, identified by one of the 26 uppercase letters from \(A\) to \(Z\). The player is not given the arrangement of cow breeds on the grid; instead, the goal is to determine the correct arrangement through a series of guesses.

Each guess is a \(3 \times 3\) grid of uppercase letters representing a possible arrangement. After a guess, some of the cells may be correctly placed. Those cells are highlighted in green. Other cells may contain a cow of the correct breed but placed in the wrong position; these are highlighted in yellow.

The number of yellow highlighted cells indicates the count of a particular breed present in the answer (excluding those already correctly positioned as green). For example, if a guess grid contains 4 cows of breed \(A\) and the answer grid contains 2 cows of breed \(A\) (none of which are in the correct positions), then only two of the guessed \(A\) cows should be highlighted in yellow. More generally, if the guess grid contains \(x\) occurrences of a particular breed, and the answer grid contains \(y \le x\) occurrences of that breed (excluding the green cells), then exactly \(y\) of the \(x\) guessed cows should be highlighted in yellow.

Your task is: given the answer grid and a guess grid, compute the number of green and yellow highlighted cells.

inputFormat

The input consists of 6 lines. The first 3 lines represent the correct answer grid, each line containing 3 uppercase letters. The next 3 lines represent the guess grid.

outputFormat

Output two integers separated by a space: the first representing the number of green highlighted cells (correct breed in the correct position), and the second representing the number of yellow highlighted cells (correct breed in the wrong position, limited by the quantity available in the answer grid after excluding the green cells).

sample

ABC
DEF
GHI
ABC
ZZZ
YYY
3 0