






'''simple docstring'''





from __future__ import annotations

from queue import Queue
def __UpperCAmelCase (			A			:	int	,   A			:	int						)  -> tuple[int, int]:
			a ^= b
			b ^= a
			a ^= b
			return a, b
def __UpperCAmelCase (			A			:	int	,   A			:	list[list[int]]						)  -> list[list[int]]:
			UpperCAmelCase_     :   Union[str, Any]       =   1
			while (1 << j) < max_node:
						for i in range(1	,   max_node + 1						):
									UpperCAmelCase_     :   Optional[int]       =   parent[j - 1][parent[j - 1][i]]
						j += 1
			return parent
def __UpperCAmelCase (			A			:	int	,   A			:	int	,   A			:	list[int]	,   A			:	list[list[int]]						)  -> int:
			# u must be deeper in the tree than v
			if level[u] < level[v]:
						UpperCAmelCase_  ,     UpperCAmelCase_     :   Optional[Any]       =   swap(A	,   A						)
			# making depth of u same as depth of v
			for i in range(1_8	,   -1	,   -1						):
						if level[u] - (1 << i) >= level[v]:
									UpperCAmelCase_     :   Union[str, Any]       =   parent[i][u]
    # at the same depth if u==v that mean lca is found
			if u == v:
						return u
			# moving both nodes upwards till lca in found
			for i in range(1_8	,   -1	,   -1						):
						if parent[i][u] not in [0, parent[i][v]]:
									UpperCAmelCase_  ,     UpperCAmelCase_     :   Union[str, Any]       =   parent[i][u], parent[i][v]
    # returning longest common ancestor of u,v
			return parent[0][u]
def __UpperCAmelCase (			A			:	list[int]	,   A			:	list[list[int]]	,   A			:	int	,   A			:	dict[int, list[int]]	,   A			:	int = 1	,   )  -> tuple[list[int], list[list[int]]]:
			UpperCAmelCase_     :   Any       =   0
			UpperCAmelCase_     :   Queue[int]       =   Queue(maxsize=A						)
			q.put(A						)
			while q.qsize() != 0:
						UpperCAmelCase_     :   str       =   q.get()
						for v in graph[u]:
									if level[v] == -1:
												UpperCAmelCase_     :   Dict       =   level[u] + 1
												q.put(A						)
												UpperCAmelCase_     :   Tuple       =   u
			return level, parent
def __UpperCAmelCase (			)  -> None:
			UpperCAmelCase_     :   str       =   1_3
			# initializing with 0
			UpperCAmelCase_     :   Tuple       =   [[0 for _ in range(max_node + 1_0						)] for _ in range(2_0						)]
			# initializing with -1 which means every node is unvisited
			UpperCAmelCase_     :   str       =   [-1 for _ in range(max_node + 1_0						)]
			UpperCAmelCase_     :   dict[int, list[int]]       =   {
			    1: [2, 3, 4],
			    2: [5],
			    3: [6, 7],
			    4: [8],
			    5: [9, 1_0],
			    6: [1_1],
			    7: [],
			    8: [1_2, 1_3],
			    9: [],
			    1_0: [],
			    1_1: [],
			    1_2: [],
			    1_3: [],
			}
			UpperCAmelCase_  ,     UpperCAmelCase_     :   List[str]       =   breadth_first_search(A	,   A	,   A	,   A	,   1						)
			UpperCAmelCase_     :   Any       =   create_sparse(A	,   A						)
			print('''LCA of node 1 and 3 is: '''	,   lowest_common_ancestor(1	,   3	,   A	,   A						)						)
			print('''LCA of node 5 and 6 is: '''	,   lowest_common_ancestor(5	,   6	,   A	,   A						)						)
			print('''LCA of node 7 and 11 is: '''	,   lowest_common_ancestor(7	,   1_1	,   A	,   A						)						)
			print('''LCA of node 6 and 7 is: '''	,   lowest_common_ancestor(6	,   7	,   A	,   A						)						)
			print('''LCA of node 4 and 12 is: '''	,   lowest_common_ancestor(4	,   1_2	,   A	,   A						)						)
			print('''LCA of node 8 and 8 is: '''	,   lowest_common_ancestor(8	,   8	,   A	,   A						)						)


if __name__ == "__main__":
						main()










'''simple docstring'''





def __UpperCAmelCase (			)  -> Optional[Any]:
			UpperCAmelCase_     :   Union[str, Any]       =   1

			while True:
						if (
						    sorted(str(A						)						)
						    == sorted(str(2 * i						)						)
						    == sorted(str(3 * i						)						)
						    == sorted(str(4 * i						)						)
						    == sorted(str(5 * i						)						)
						    == sorted(str(6 * i						)						)
						):
									return i

						i += 1


if __name__ == "__main__":
						print(solution())


