Under construction

Still being built. Things may change

Byte Me!

Time limit2sMemory limit512 MB

Summary
Given N data bytes and a parity byte, find the parity type, the one data byte with wrong popcount parity, and the flipped bit position.
Level

Medium4 of 10

Topics
Bit manipulation, Implementation, Array
Solved
No attempts yet

Problem

Parity is one way to check data transmission for errors. Transmission is not error proof, so parity tells you whether the data was corrupted on the way.

Under even parity every byte contains an even number of 1 characters. Under odd parity every byte contains an odd number of 1 characters.

In this problem you look for a single corrupted bit. The last byte of the input is not part of the transmitted data. It is a parity byte: bit jj of the parity byte is the parity bit for bit jj of the NN data bytes, and it uses the same parity as the data bytes. For every position jj, counting bit jj of the NN data bytes together with bit jj of the parity byte matches the parity in use.

Exactly one bit of one data byte was flipped. That byte is the only data byte whose number of 1 characters disagrees with the parity in use, and the flipped position is the only position whose column disagrees with it. Report the parity in use, the broken byte, and the broken bit.

Input

The first line contains an integer NN (3≤N≤103 \le N \le 10), the number of data bytes. Each of the next NN lines contains one byte as 8 characters separated by single spaces. Each character is 0 or 1.

One more line follows in the same format, the parity byte. Its bit jj is the parity bit for position jj of the preceding NN lines and uses the same parity as the data bytes. The number of 1 characters inside the parity byte itself need not match that parity.

Output

Print three lines.

  • Line 1: Even if the bytes that are not broken use even parity, Odd if they use odd parity.
  • Line 2: Byte B is broken, where B is the number of the broken byte. The first data byte is number 1.
  • Line 3: Bit C is broken, where C is the position of the broken bit inside its byte. The leftmost position is number 1.

Examples2

  1. Example 1

    Input
    3
    1 0 1 0 1 1 1 0
    1 1 0 1 1 1 0 0
    1 0 1 1 1 0 0 0
    0 0 1 1 1 1 0 1
    
    Expected output
    Odd
    Byte 3 is broken
    Bit 5 is broken
    
  2. Example 2

    Input
    4
    1 0 1 1 1 0 0 0
    1 0 1 1 0 0 0 0
    0 1 0 0 1 0 0 0
    1 0 1 1 1 0 1 1
    1 0 1 1 1 0 1 1
    
    Expected output
    Even
    Byte 2 is broken
    Bit 2 is broken