One day, Umaru was enjoying Coke and potato chips as usual. Suddenly, an intellectual problem appeared on the television and the person who asked the problem first and correctly will get the latest《Jump》. Umaru really wants to get the 《Jump》so she told her brother the problem and begged him to help her. But her brother didn’t know how to do it, so he told you the problem and asked you for help.
There was a $N×N$ matrix and each grid is black or white. The host reversed the color of the grid or reversed the color of the whole columns. Then the problem was how many white and black connected components. (If two grids have a common edge, we think they are connected.) To increase difficulty, the grid $(i,1)$ and the grid $(i,N)$ are connected. $(1\leq i \leq N)$.