import java.util.Scanner;


public class Reinier {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		char[][] lines = new char[h][];
		for (int i = 0; i < h; i++) {
			lines[i] = scanner.next().toCharArray();
		}
		
		int[][] A = new int[w][h];
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				switch (lines[y][x]) {
				case 'w': A[x][y] = 1; break;
				case 'r': A[x][y] = 2; break;
				case 'g': A[x][y] = 4; break;
				case 'b': A[x][y] = 8; break;
				}
			}
		}
		
		int g = gcd(w, h);
		for (int x1 = 0; x1 < w; x1++) {
			for (int x2 = 0; x2 < w; x2++) {
				boolean[][] B = new boolean[g][1<<4];
				for (int y = 0; y < h; y++) {
					int v = A[x1][y] | A[x2][y];
					B[y%g][v] = true;
					if (B[((y+x2-x1)%g+g)%g][(1<<4)-1-v]) {
						System.out.println("possible");
						return;
					}
				}
			}
		}
		System.out.println("impossible");
	}

	public static int gcd(int a, int b) {
		while (b != 0) {
			a %= b;
			int t = a;
			a = b;
			b = t;
		}
		return a;
	}
}
