CF811E Vladik and Entertaining Flags

Description

In his spare time Vladik estimates beauty of the flags. Every flag could be represented as the matrix $ n×m $ which consists of positive integers. Let's define the beauty of the flag as number of components in its matrix. We call component a set of cells with same numbers and between any pair of cells from that set there exists a path through adjacent cells from same component. Here is the example of the partitioning some flag matrix into components: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF811E/9c3d5d03c8614a33f231cd8f8efd0e706383885b.png)But this time he decided to change something in the process. Now he wants to estimate not the entire flag, but some segment. Segment of flag can be described as a submatrix of the flag matrix with opposite corners at $ (1,l) $ and $ (n,r) $ , where conditions $ 1

Input Format

N/A

Output Format

N/A

Explanation/Hint

Partitioning on components for every segment from first test case: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF811E/d3d891fc856386c8b0c1e1a004521369cd8ed774.png)