The auditorium for a closing ceremony has many seats arranged in a large rectangular grid. For security, an expert has fixed the exact number of bodyguards that must be seated in each row and in each column.
You are given the required number of bodyguards for every row and every column, provided in the compressed (grouped) form described below. The auditorium starts empty and each seat may hold at most one bodyguard. Decide whether it is possible to seat the bodyguards so that every row and every column contains exactly its required number of bodyguards.
The input first describes the rows.
The input then describes the columns.
Print a single line containing 1 if the requirements can be satisfied, or 0 otherwise.