Problem: You are given a matrix , consisting of rows by columns. Each element of the matrix is equal to or .
You can perform the following operation any number of times (possibly zero): choose an element of the matrix and replace it with either or .
You are also given two arrays and (of length and respectively). After you perform the operations, the matrix should satisfy the following conditions:
- the number of ones in the -th row of the matrix should be exactly for every .
- the number of ones in the -th column of the matrix should be exactly for every .
Calculate the minimum number of operations you have to perform.
Input Format: The first line contains two integers and ().
Then lines follow. The -th of them contains integers ().
The next line contains integers ().
The next line contains integers ().
Output Format: Print one integer — the minimum number of operations you have to perform, or -1 if it is impossible.