import sequtils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord let h = scan() let w = scan() proc encode(x,y:int):int = x * h + y let n = h * w var C = newSeqWith(w,newSeqWith(h,'.')) for y in 0..= w or ny >= h : continue if C[nx][ny] == '.' : continue F.add(encode(x,y),encode(nx,ny),1) var ans = F.fordFullkerson(n+1,n) wSum -= ans bSum -= ans ans *= 100 let pair = min(bSum,wSum) ans = ans + 10 * pair wSum -= pair bSum -= pair echo ans + wSum + bSum