There are two types of persons:

*   The **good person**: The person who always tells the truth.
*   The **bad person**: The person who might tell the truth and might lie.

You are given a **0-indexed** 2D integer array `statements` of size `n x n` that represents the statements made by `n` people about each other. More specifically, `statements[i][j]` could be one of the following:

*   `0` which represents a statement made by person `i` that person `j` is a **bad** person.
*   `1` which represents a statement made by person `i` that person `j` is a **good** person.
*   `2` represents that **no statement** is made by person `i` about person `j`.

Additionally, no person ever makes a statement about themselves. Formally, we have that `statements[i][i] = 2` for all `0 <= i < n`.

Return _the **maximum** number of people who can be **good** based on the statements made by the_ `n` _people_.

**Example 1:**

**Input:** statements = \[\[2,1,2\],\[1,2,2\],\[2,0,2\]\]
**Output:** 2
**Explanation:** Each person makes a single statement.
- Person 0 states that person 1 is good.
- Person 1 states that person 0 is good.
- Person 2 states that person 1 is bad.
Let's take person 2 as the key.
- Assuming that person 2 is a good person:
    - Based on the statement made by person 2, person 1 is a bad person.
    - Now we know for sure that person 1 is bad and person 2 is good.
    - Based on the statement made by person 1, and since person 1 is bad, they could be:
        - telling the truth. There will be a contradiction in this case and this assumption is invalid.
        - lying. In this case, person 0 is also a bad person and lied in their statement.
    - 

from collections import defaultdict, deque


def network_becomes_idle(edges, patience):
    n = len(patience)
    graph = defaultdict(list)

    for edge in edges:
        graph[edge[0]].append(edge[1])
        graph[edge[1]].append(edge[0])

    dist = [-1] * n
    dist[0] = 0
    q = deque([0])

    while q:
        node = q.popleft()

        for neighbor in graph[node]:
            if dist[neighbor] == -1:
                dist[neighbor] = dist[node] + 1
                q.append(neighbor)

    max_time = 0
    for i in range(1, n):
        time = ((2 * dist[i] - 1) // patience[i]) * patience[i] + 2 * dist[i]
        max_time = max(max_time, time)

    return max_time + 1
