Percolation ptoblem for Coursera.