s='#';n,*a=open(0).readlines();n=int(n);f,e=[sum(i==t.count(s)for t in zip(*a))for i in(n,0)];r=list(range(n));print((-(e>n)or min(n*2-f-a[i].count(s)+all(s<a[j][i]for j in r)for i in r)))
n,*a=open(0).readlines();n=int(n);f,e=[sum(n==t.count(c)for t in zip(*a))for c in'#.'];r=list(range(n));print((-(e==n)or min(n*2-f-a[i].count('#')+all('#'<a[j][i]for j in r)for i in r)))
s = "#"
n, *a = open(0).readlines()
n = int(n)
f, e = [sum(i == t.count(s) for t in zip(*a)) for i in (n, 0)]
r = list(range(n))
print(
    (
        -(e > n)
        or min(n * 2 - f - a[i].count(s) + all(s < a[j][i] for j in r) for i in r)
    )
)

n, *a = open(0).readlines()
n = int(n)
f, e = [sum(n == t.count(c) for t in zip(*a)) for c in "#."]
r = list(range(n))
print(
    (
        -(e == n)
        or min(n * 2 - f - a[i].count("#") + all("#" < a[j][i] for j in r) for i in r)
    )
)

-s = "#" -f, e = [sum(i == t.count(s) for t in zip(*a)) for i in (n, 0)] +f, e = [sum(n == t.count(c) for t in zip(*a)) for c in "#."] -        -(e > n) -        or min(n * 2 - f - a[i].count(s) + all(s < a[j][i] for j in r) for i in r) +        -(e == n) +        or min(n * 2 - f - a[i].count("#") + all("#" < a[j][i] for j in r) for i in r)