Example 1

Example 2

Example 3

2 <= n <= 5 * 1041 <= edges.length <= 105edges[i] = [ui, vi]0 <= ui < vi < nAll the edges are distinct.The input is generated such that edges can form a 2D grid that satisfies the conditions.Example 1

Example 2

Example 3

2 <= n <= 5 * 1041 <= edges.length <= 105edges[i] = [ui, vi]0 <= ui < vi < nAll the edges are distinct.The input is generated such that edges can form a 2D grid that satisfies the conditions.