using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static int vremedosl(int i,int j, int[,] tabla,char fig, int poci, int pocj)
        {
            if (tabla[i + 1, j] != 0 || tabla[i, j + 1] != 0 || tabla[i + 1, j + 1] != 0 )
                i++;
            return 1;
        }
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split();
            int n = int.Parse(x[0]);
            int m = int.Parse(x[1]);
            int[,] tabla = new int[n, m];
            int t = 0;
            for (int i = 0; i < n; i++)
            {
                string y = Console.ReadLine();
                for (int j = 0; j < m; j++)
                {
                    if (y[j] == '#')
                        tabla[i, j] = 0;
                    if (y[j] == '.')
                        tabla[i, j] = 1;
                }
            }
            if(t==0)
                Console.WriteLine("-1");
        }
    }
}