The Alliances

Time limit1sMemory limit128 MB

Problem

In a fantasy world there is a large island shaped as a rectangle. Its two sides are exactly R and C miles long, and the whole island is divided into a grid of areas. Some areas are uninhabited; the rest are occupied by villages of fantasy beings: elves, humans, dwarves, and hobbits. Each area contains at most one village. Two villages are neighbours if their areas share a side.

Recently the villages became terrified of the Great Evil. To feel safer, each village decided to form military alliances with some of its neighbours. An alliance always involves two neighbouring villages and is a mutual, symmetric agreement.

Depending on the species living in the village, its inhabitants do not feel safe unless a specific configuration of alliances is formed:

  • Elves are confident and need exactly one alliance.
  • Human villages need alliances with exactly two neighbours. Moreover, leaving two opposite sides of the village exposed is tactically bad, so the two allied neighbours must not be on opposite sides of the village. (In other words, they cannot be the two vertical neighbours nor the two horizontal ones; a human must ally exactly one horizontal neighbour and exactly one vertical neighbour.)
  • Dwarves need alliances with exactly three neighbours.
  • Hobbits are extremely scared and need alliances with all four of their neighbours.

In other words, apart from humans each village requires a particular number of alliances and does not care which neighbours become its allies. Only humans have the extra restriction that the allied neighbours must not be on opposite sides.

These conditions must hold regardless of the village's position on the map. For example, a dwarf village wants three alliances; on the coast (edge) this means it must ally all three of its neighbours, and a dwarf village in a corner can never feel safe.

For each species the possible layouts of alliances are shown below (O is the village itself, X is an ally, . is empty):

 -elves---------------       -humans--------------       -dwarves-------------       -hobbits------------- 
|...   .X.   ...   ...|     |.X.   .X.   ...   ...|     |.X.   .X.   .X.   ...|     |.X.                  |
|.OX   .O.   XO.   .O.|     |.OX   XO.   XO.   .OX|     |.OX   XOX   XO.   XOX|     |XOX                  |
|...   ...   ...   .X.|     |...   ...   .X.   .X.|     |.X.   ...   .X.   .X.|     |.X.                  |
 ---------------------       ---------------------       ---------------------       --------------------- 

For a given island, decide whether it is possible to form alliances so that all inhabitants feel safe.

Input

The first line contains two integers R and C, the size of the island. Each of the next R lines contains C space-separated integers between 0 and 4:

  • 0 means an uninhabited area,
  • 1 means an elf village,
  • 2 means a human village,
  • 3 means a dwarf village,
  • 4 means a hobbit village.

(The number in the input always equals the number of alliances that village desires.)

Output

Print "Possible" (without quotes) on a single line if alliances can be formed so that every inhabitant feels safe; otherwise print "Impossible!".

Constraints

In all test cases 1 ≤ R, C ≤ 70.