


from __future__ import annotations

from typing import Generic, TypeVar

_A		       =						TypeVar('T')






class     UpperCAmelCase__       (					Generic[T]		):



    """simple docstring"""






    def __init__(			self					,   A_    )  ->       None:
         __UpperCamelCase    							=data
         __UpperCamelCase    							=self
         __UpperCamelCase    							=0






class     UpperCAmelCase__       (					Generic[T]		):



    """simple docstring"""






    def __init__(			self    )  ->       None:
         __UpperCamelCase    							={}






    def _a					(			self					,   A_    )  ->       None:
         __UpperCamelCase    							=DisjointSetTreeNode(_snake_case    )






    def _a					(			self					,   A_    )  ->       DisjointSetTreeNode[T]:
         __UpperCamelCase    							=self.map[data]
         if elem_ref != elem_ref.parent:
              __UpperCamelCase    							=self.find_set(elem_ref.parent.data    )
         return elem_ref.parent






    def _a					(			self					,   A_					,   A_    )  ->       None:



         if nodea.rank > nodea.rank:
              __UpperCamelCase    							=nodea
         else:
              __UpperCamelCase    							=nodea
              if nodea.rank == nodea.rank:
                   nodea.rank += 1






    def _a					(			self					,   A_					,   A_    )  ->       None:
         self.link(self.find_set(_snake_case    )					,   self.find_set(_snake_case    )    )






class     UpperCAmelCase__       (					Generic[T]		):



    """simple docstring"""






    def __init__(			self    )  ->       None:
         __UpperCamelCase    							={}






    def _a					(			self					,   A_    )  ->       None:



         if node not in self.connections:
              __UpperCamelCase    							={}






    def _a					(			self					,   A_					,   A_					,   A_    )  ->       None:
         self.add_node(_snake_case    )
         self.add_node(_snake_case    )
         __UpperCamelCase    							=weight
         __UpperCamelCase    							=weight






    def _a					(			self    )  ->       GraphUndirectedWeighted[T]:
         __UpperCamelCase    							=[]
         __UpperCamelCase    							=set()
         for start in self.connections:
              for end in self.connections[start]:
                   if (start, end) not in seen:
                        seen.add((end, start)    )
                        edges.append((start, end, self.connections[start][end])    )
         edges.sort(key=lambda A_    : x[2]    )

         # creating the disjoint set
         __UpperCamelCase    							=DisjointSetTree[T]()
         for node in self.connections:
              disjoint_set.make_set(_snake_case    )

         # MST generation
         __UpperCamelCase    							=0
         __UpperCamelCase    							=0
         __UpperCamelCase    							=GraphUndirectedWeighted[T]()
         while num_edges < len(self.connections    ) - 1:
              __UpperCamelCase    							=edges[index]
              index += 1
              __UpperCamelCase    							=disjoint_set.find_set(_snake_case    )
              __UpperCamelCase    							=disjoint_set.find_set(_snake_case    )
              if parent_u != parent_v:
                   num_edges += 1
                   graph.add_edge(_snake_case					,   _snake_case					,   _snake_case    )
                   disjoint_set.union(_snake_case					,   _snake_case    )
         return graph










"""simple docstring"""







def      __UpperCAmelCase      (    __lowerCamelCase = 50	)							->      int:
		lowercase__   :    int				=			[[0] * 3 for _ in range(length + 1	)]

		for row_length in range(length + 1	):
				for tile_length in range(2						,     5	):
						for tile_start in range(row_length - tile_length + 1	):
								different_colour_ways_number[row_length][tile_length - 2] += (
								    different_colour_ways_number[row_length - tile_start - tile_length][
								        tile_length - 2
								    ]
								    + 1
								)

		return sum(different_colour_ways_number[length]	)


if __name__ == "__main__":
							print(F'''{solution() = }''')
