In most puzzles we are given some pieces and we have to make a target pattern which can be built in only one possible way. But some puzzles are a bit different, we are given a target pattern and from that target pattern we have to find in how many ways the pieces can be placed. Such a puzzle is the puzzle of overlapping squares. To understand this puzzle, look at the pictures below:
[tu pian]
In first figure we have placed a (2x2) filled square in a (4x4) grid. In the second figure we have placed another (2x2) filled square in the grid, which have of course deleted some part of the black lines of the previous square, in third picture we have placed a third square and in the fourth picture we have placed a fourth square. The picture can become even more complex if we place more (2x2) squares. Write a program to determine if it's possible to form a target image using at most six pieces of 2x2 squares.