#P2280. Tetris Comes Back

Tetris Comes Back

Problem Description

Working in corporation is toilsome and rest is important. In leisure time, WisKey like to play Tetris. The Tetris game in board is N*5, and there are 8 kinds of blocks.
  Look that, red mean the area can’t be place. Other colors mean different kinds of blocks. If I give you C grey blocks (the 1st kind), and other infinite color blocks, Can you fulfil the board without any blocks overlap.

Input

Each case will contain two integers N (1<=N<=1000) and C (0<=C<=100).
N*5 grid follow it. The ‘1’ represent red area, it can’t be place. The ‘0’ represent normal area.
Process cases to end of file.

Output

If you can full of the Tetris, print “YES”, otherwise, print “NO”.

1 1 00000 1 1 00100 1 1 01010 4 1 10000 00101 10010 00000
YES YES NO YES