The same idea as island, first, we look up if current student is used or not, then assign it as used and look up its neighbor, then do some modify. While in the island, we do the same thing: look up the neighbor and do some modify. But here our neighbor is different.
Error:
1. Do not too much understand what our doing, I think we can use M[i][i] to specify if current student is used or not.