This page is still under construction.

Parts of this page are still being built. What you see may change.

Xortris

Time limit1sMemory limit256 MB

Summary
Decide whether the black cells of a board of up to 100 by 100 cells can all be turned white by repeatedly flipping four cells covered by a tetromino.
Level

Hard8 of 10

Topics
Math, Combinatorics
Solved
No attempts yet

Problem

It is 1990 and you work in the development team of a video game that will change arcades. The player gets a rectangular board of white and black squares. The goal is to turn the whole board white. On each turn the player may pick a tetromino from an infinite supply, move and rotate it so that the piece lies entirely inside the board, and flip the color of the four squares it covers. A tetromino is a set of four squares joined edge to edge into one connected piece (Figure 1).

The testing team keeps complaining that some levels cannot be solved at all. The testers are skilled enough to place a piece in any position and rotation they need, so the cause is somewhere else. Your next debugging step is to write a program that decides whether a level can be solved.

Figure 1: all tetrominoes. Source: Wikimedia.

Input

The first line contains two integers mm and nn (1≤m,n≤1001 \le m, n \le 100), the dimensions of the board. Then follow mm lines with nn characters each. The character . is a white square and the character X is a black square.

Output

Print one line with possible if the level can be solved and impossible if it cannot.

Examples2

  1. Example 1

    Input
    3 3
    ...
    ...
    ...
    
    Expected output
    possible
    
  2. Example 2

    Input
    3 3
    XXX
    XXX
    XXX
    
    Expected output
    impossible