QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100

#4321. Matching

Statistiques

A "match" is defined as a string of length $L$ where each character is either '0' or '1'. We are given $N$ such "matches", and we want to design a "scheme", which is also a string of length $L$ consisting of '0's and '1's. The error value of a "match" is defined as the number of positions where the "scheme" and the "match" differ. For example, if the "match" is 101 and the "scheme" is 000, the first and third positions differ, so the error value for this "match" is 2. We want to find a "scheme" such that the sum of the error values for all $N$ "matches" is minimized. Additionally, there are $M$ distinct forbidden "schemes", and the "scheme" we choose must not be one of these forbidden "schemes".

Input

The first line contains three positive integers $N, M, L$, where $1 \le N \le 1000$, $1 \le M \le \min(1000, 2^L-1)$, and $1 \le L \le 1000$.

The next $N$ lines each contain a string of length $L$, followed by $M$ lines, each containing a string of length $L$.

Output

Output a single integer representing the minimum sum of error values for the $N$ "matches" using a valid "scheme".

Examples

Input 1

4 1 4
0000
1000
1100
1010
1000

Output 1

5

Input 2

2 4 4
0000
0000
0000
1000
0100
0010

Output 2

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.