
class 					_SCREAMING_SNAKE_CASE  :  # Public class to implement a graph
    def __init__(			self		,	lowerCamelCase		,	lowerCamelCase		,	lowerCamelCase ):
        snake_case__						=				row
        snake_case__						=				col
        snake_case__						=				graph
    def A_			(			self		,	lowerCamelCase		,	lowerCamelCase		,	lowerCamelCase ):
        return (
            0 <= i < self.ROW
            and 0 <= j < self.COL
            and not visited[i][j]
            and self.graph[i][j]
        )
    def A_			(			self		,	lowerCamelCase		,	lowerCamelCase		,	lowerCamelCase ):
        # Checking all 8 elements surrounding nth element
        snake_case__						=				[-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
        snake_case__						=				[-1, 0, 1, -1, 1, -1, 0, 1]
        snake_case__						=				True  # Make those cells visited
        for k in range(8 ):
            if self.is_safe(i + row_nbr[k]		,	j + col_nbr[k]		,	lowerCamelCase ):
                self.diffs(i + row_nbr[k]		,	j + col_nbr[k]		,	lowerCamelCase )



    def A_			(			self ):  # And finally, count all islands.
        snake_case__						=				[[False for j in range(self.COL )] for i in range(self.ROW )]
        snake_case__						=				0
        for i in range(self.ROW ):
            for j in range(self.COL ):
                if visited[i][j] is False and self.graph[i][j] == 1:
                    self.diffs(lowerCamelCase		,	lowerCamelCase		,	lowerCamelCase )
                    count += 1
        return count





# 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 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase							):
    snake_case__						=				[False] * len(__lowerCAmelCase							)
    snake_case__						=				[-1] * len(__lowerCAmelCase							)

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

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

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

    return True


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





print(check_bipartite_dfs(graph))



