




"""simple docstring"""




from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload






class 					__magic_name__							:






				'''simple docstring'''





				def __init__( self	,				_a = None				):





							"""simple docstring"""






							if components is None:
										lowerCamelCase       =      []
							lowerCamelCase       =      list(__a				)





				def __len__( self				):





							"""simple docstring"""
							return len(self.__components				)





				def __str__( self				):





							"""simple docstring"""
							return "(" + ",".join(map(__a	,				self.__components				)				) + ")"





				def __add__( self	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      len(self				)
							if size == len(__a				):
										lowerCamelCase       =      [self.__components[i] + other.component(__a				) for i in range(__a				)]
										return Vector(__a				)
							else:
										raise Exception("""must have the same size"""				)





				def __sub__( self	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      len(self				)
							if size == len(__a				):
										lowerCamelCase       =      [self.__components[i] - other.component(__a				) for i in range(__a				)]
										return Vector(__a				)
							else:  # error case
										raise Exception("""must have the same size"""				)





				@overload
				def __mul__( self	,				_a				):





							"""simple docstring"""
							...





				@overload
				def __mul__( self	,				_a				):





							"""simple docstring"""
							...





				def __mul__( self	,				_a				):





							"""simple docstring"""






							if isinstance(__a	,				(float, int)				):
										lowerCamelCase       =      [c * other for c in self.__components]
										return Vector(__a				)
							elif isinstance(__a	,				__a				) and len(self				) == len(__a				):
										lowerCamelCase       =      len(self				)
										lowerCamelCase       =      [self.__components[i] * other.component(__a				) for i in range(__a				)]
										return sum(__a				)
							else:  # error case
										raise Exception("""invalid operand!"""				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							return Vector(self.__components				)





				def      _lowerCAmelCase       ( self	,				_a				):





							"""simple docstring"""






							if isinstance(__a	,				__a				) and -len(self.__components				) <= i < len(self.__components				):
										return self.__components[i]
							else:
										raise Exception("""index out of range"""				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a				):





							"""simple docstring"""
							assert -len(self.__components				) <= pos < len(self.__components				)
							lowerCamelCase       =      value





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""






							if len(self.__components				) == 0:
										raise Exception("""Vector is empty"""				)
							lowerCamelCase       =      [c**2 for c in self.__components]
							return math.sqrt(sum(__a				)				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a = False				):





							"""simple docstring"""
							lowerCamelCase       =      self * other
							lowerCamelCase       =      self.euclidean_length() * other.euclidean_length()
							if deg:
										return math.degrees(math.acos(num / den				)				)
							else:
										return math.acos(num / den				)




def 					a__				(       snake_case__       )		->      Vector:
			assert isinstance(snake_case__ ,				snake_case__       )
			return Vector([0] * dimension       )



def 					a__				(       snake_case__ ,				snake_case__       )		->      Vector:
			assert isinstance(snake_case__ ,				snake_case__       ) and (isinstance(snake_case__ ,				snake_case__       ))
			lowerCamelCase       =      [0] * dimension
			lowerCamelCase       =      1
			return Vector(snake_case__       )



def 					a__				(       snake_case__ ,				snake_case__ ,				snake_case__       )		->      Vector:
			assert (
			    isinstance(snake_case__ ,				snake_case__       )
			    and isinstance(snake_case__ ,				snake_case__       )
			    and (isinstance(snake_case__ ,				(int, float)       ))
			)
			return x * scalar + y



def 					a__				(       snake_case__ ,				snake_case__ ,				snake_case__       )		->      Vector:
			random.seed(snake_case__       )
			lowerCamelCase       =      [random.randint(snake_case__ ,				snake_case__       ) for _ in range(snake_case__       )]
			return Vector(snake_case__       )






class 					__magic_name__							:






				'''simple docstring'''





				def __init__( self	,				_a	,				_a	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      matrix
							lowerCamelCase       =      w
							lowerCamelCase       =      h





				def __str__( self				):





							"""simple docstring"""
							lowerCamelCase       =      ''
							for i in range(self.__height				):
										ans += "|"
										for j in range(self.__width				):
													if j < self.__width - 1:
																ans += str(self.__matrix[i][j]				) + ","
													else:
																ans += str(self.__matrix[i][j]				) + "|\n"
							return ans





				def __add__( self	,				_a				):





							"""simple docstring"""






							if self.__width == other.width() and self.__height == other.height():
										lowerCamelCase       =      []
										for i in range(self.__height				):
													lowerCamelCase       =      [
													    self.__matrix[i][j] + other.component(__a	,				__a				)
													    for j in range(self.__width				)
													]
													matrix.append(__a				)
										return Matrix(__a	,				self.__width	,				self.__height				)
							else:
										raise Exception("""matrix must have the same dimension!"""				)





				def __sub__( self	,				_a				):





							"""simple docstring"""






							if self.__width == other.width() and self.__height == other.height():
										lowerCamelCase       =      []
										for i in range(self.__height				):
													lowerCamelCase       =      [
													    self.__matrix[i][j] - other.component(__a	,				__a				)
													    for j in range(self.__width				)
													]
													matrix.append(__a				)
										return Matrix(__a	,				self.__width	,				self.__height				)
							else:
										raise Exception("""matrices must have the same dimension!"""				)





				@overload
				def __mul__( self	,				_a				):





							"""simple docstring"""
							...





				@overload
				def __mul__( self	,				_a				):





							"""simple docstring"""
							...





				def __mul__( self	,				_a				):





							"""simple docstring"""






							if isinstance(__a	,				__a				):  # matrix-vector
										if len(__a				) == self.__width:
													lowerCamelCase       =      zero_vector(self.__height				)
													for i in range(self.__height				):
																lowerCamelCase       =      [
																    self.__matrix[i][j] * other.component(__a				)
																    for j in range(self.__width				)
																]
																ans.change_component(__a	,				sum(__a				)				)
													return ans
										else:
													raise Exception(
													    """vector must have the same size as the """
													    """number of columns of the matrix!"""				)
							elif isinstance(__a	,				(int, float)				):  # matrix-scalar
										lowerCamelCase       =      [
										    [self.__matrix[i][j] * other for j in range(self.__width				)]
										    for i in range(self.__height				)
										]
										return Matrix(__a	,				self.__width	,				self.__height				)
							return None





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							return self.__height





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							return self.__width





				def      _lowerCAmelCase       ( self	,				_a	,				_a				):





							"""simple docstring"""






							if 0 <= x < self.__height and 0 <= y < self.__width:
										return self.__matrix[x][y]
							else:
										raise Exception("""change_component: indices out of bounds"""				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a	,				_a				):





							"""simple docstring"""






							if 0 <= x < self.__height and 0 <= y < self.__width:
										lowerCamelCase       =      value
							else:
										raise Exception("""change_component: indices out of bounds"""				)





				def      _lowerCAmelCase       ( self	,				_a	,				_a				):





							"""simple docstring"""






							if self.__height != self.__width:
										raise Exception("""Matrix is not square"""				)
							lowerCamelCase       =      self.__matrix[:x] + self.__matrix[x + 1 :]
							for i in range(len(__a				)				):
										lowerCamelCase       =      minor[i][:y] + minor[i][y + 1 :]
							return Matrix(__a	,				self.__width - 1	,				self.__height - 1				).determinant()





				def      _lowerCAmelCase       ( self	,				_a	,				_a				):





							"""simple docstring"""






							if self.__height != self.__width:
										raise Exception("""Matrix is not square"""				)
							if 0 <= x < self.__height and 0 <= y < self.__width:
										return (-1) ** (x + y) * self.minor(__a	,				__a				)
							else:
										raise Exception("""Indices out of bounds"""				)





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""






							if self.__height != self.__width:
										raise Exception("""Matrix is not square"""				)
							if self.__height < 1:
										raise Exception("""Matrix has no element"""				)
							elif self.__height == 1:
										return self.__matrix[0][0]
							elif self.__height == 2:
										return (
										    self.__matrix[0][0] * self.__matrix[1][1]
										    - self.__matrix[0][1] * self.__matrix[1][0]
										)
							else:
										lowerCamelCase       =      [
										    self.__matrix[0][y] * self.cofactor(0	,				__a				) for y in range(self.__width				)
										]
										return sum(__a				)




def 					a__				(       snake_case__       )		->      Matrix:
			lowerCamelCase       =      [[0] * n for _ in range(snake_case__       )]
			return Matrix(snake_case__ ,				snake_case__ ,				snake_case__       )



def 					a__				(       snake_case__ ,				snake_case__ ,				snake_case__ ,				snake_case__       )		->      Matrix:
			random.seed(snake_case__       )
			lowerCamelCase       =      [
			    [random.randint(snake_case__ ,				snake_case__       ) for _ in range(snake_case__       )] for _ in range(snake_case__       )
			]
			return Matrix(snake_case__ ,				snake_case__ ,				snake_case__       )









"""simple docstring"""




# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# or u belongs to V and v to U. We can also say that there is no edge that connects
# vertices of same set.



def 					a__				(       snake_case__       )		->      Dict:
			lowerCamelCase       =      [False] * len(snake_case__       )
			lowerCamelCase       =      [-1] * len(snake_case__       )

			def dfs(snake_case__ ,				snake_case__       ):
						lowerCamelCase       =      True
						lowerCamelCase       =      c
						for u in graph[v]:
									if not visited[u]:
												dfs(snake_case__ ,				1 - c       )

			for i in range(len(snake_case__       )       ):
						if not visited[i]:
									dfs(snake_case__ ,				0       )

			for i in range(len(snake_case__       )       ):
						for j in graph[i]:
									if color[i] == color[j]:
												return False

			return True


# Adjacency list of graph
lowerCAmelCase							:    str  							=							{0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2], 4: []}


print(check_bipartite_dfs(graph))



