/******************************************************************/
/* ACM ICPC 2017-2018, NEERC                                      */
/* Northern Subregional Contest                                   */
/* St Petersburg, November 4, 2017                                */
/******************************************************************/
/* Problem K. Kotlin Island                                       */
/*                                                                */
/* Original idea         Mikhail Dvorkin                          */
/* Problem statement     Mikhail Dvorkin                          */
/* Test set              Mikhail Dvorkin                          */
/******************************************************************/
/* Checker                                                        */
/*                                                                */
/* Author                Mikhail Dvorkin                          */
/******************************************************************/

import ru.ifmo.testlib.*;
import static ru.ifmo.testlib.Outcome.Type.*;

public class Check implements Checker {
    public static final String IMPOSSIBLE = "Impossible";
    public static final char DRY_LAND = '.';
    public static final char WATER = '#';

    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        int h = inf.nextInt();
        int w = inf.nextInt();
        int n = inf.nextInt();

        String ja = ans.nextLine();
        boolean jaImpossible = ja.equals(IMPOSSIBLE);

        String[] pa = new String[h];
        pa[0] = ouf.nextLine();

        if (pa[0].equals(IMPOSSIBLE)) {
            if (jaImpossible) {
                return new Outcome(OK, IMPOSSIBLE);
            }
            return new Outcome(WA, "Expected solution but found " + IMPOSSIBLE);
        }

        for (int i = 1; i < h; i++) {
            pa[i] = ouf.nextLine();
        }

        boolean[] rowHasLand = new boolean[h];
        boolean[] colHasLand = new boolean[w];
        for (int i = 0; i < h; i++) {
            if (pa[i].length() != w) {
                return new Outcome(WA, "Line " + i + " has wrong width");
            }
            for (int j = 0; j < w; j++) {
                char c = pa[i].charAt(j);
                if (c == DRY_LAND) {
                    rowHasLand[i] = colHasLand[j] = true;
                } else if (c != WATER) {
                    return new Outcome(WA, "Invalid char with code " + (int) c);
                }
            }
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                char c = pa[i].charAt(j);
                if ((c == DRY_LAND) ^ (rowHasLand[i] && colHasLand[j])) {
                    return new Outcome(WA, "Plan cannot be fulfilled");
                }
            }
        }

        int components = components(rowHasLand) * components(colHasLand);
        if (components != n) {
            return new Outcome(WA, components + " blocks instead of " + n);
        }
        return new Outcome(OK, n + " blocks");
    }

    int components(boolean[] a) {
        int res = 0;
        for (int i = 0; i < a.length; i++) {
            if (a[i] && (i == 0 || !a[i - 1])) {
                res++;
            }
        }
        return res;
    }
}

