Hide

Problem F
LED Game

You are given two $n$ by $n$ boards of LED lights, each light is either off or on (represented by $0$ and $1$ respectively).

Next to each row, and above each column of each board is a button “flip”, which, for every LED in that row or column, turns that LED from off to on or on to off.

Determine the maximum number of LEDs you can get to match on the two boards.

Input

The first line of input is an integer $n$, where $1 \leq n \leq 14$.

The first $n$ lines of input are length-$n$ strings of $0$s and $1$s, where $0$ indicates that the corresponding light is off, and $1$ indicates that it is on. These $n$ lines represent the first board.

The next $n$ lines are length-$n$ strings of $0$s and $1$s. These $n$ lines represent the second board.

Output

Output the maximum number of LEDs you can get to match on the two boards.

Sample Input 1 Sample Output 1
2
10
01
00
00
4
Sample Input 2 Sample Output 2
3
000
100
100
111
111
111
8

Please log in to submit a solution to this problem

Log in