A = [[0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 1, 
    0, 1, 0], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]


def Distancias(n, origem):
    d = [-1] * n
    d[origem] = 0
    f = []
    f.append(origem)
    while len(f) > 0:
        x = f[0]
        del f[0]
        for y in range(n):
            if A[x][y] == 1 and d[y] == -1:
                d[y] = d[x] + 1
                f.append(y)
    return d


print(Distancias(6, 3))

ac9b316e6499ca00d2ec5aad6224d857e1967b42
<mask token>

<mask token>


def Distancias(n, origem):
    d = [-1] * n
    d[origem] = 0
    f = []
    f.append(origem)
    while len(f) > 0:
        x = f[0]
        del f[0]
        for y in range(n):
            if A[x][y] == 1 and d[y] == -1:
                d[y] = d[x] + 1
                f.append(y)
    return d


<mask token>

<mask token>


def Distancias(n, origem):
    d = [-1] * n
    d[origem] = 0
    f = []
    f.append(origem)
    while len(f) > 0:
        x = f[0]
        del f[0]
        for y in range(n):
            if A[x][y] == 1 and d[y] == -1:
                d[y] = d[x] + 1
                f.append(y)
    return d


print(Distancias(6, 3))

A = [[0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 1, 
    0, 1, 0], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]


def Distancias(n, origem):
    d = [-1] * n
    d[origem] = 0
    f = []
    f.append(origem)
    while len(f) > 0:
        x = f[0]
        del f[0]
        for y in range(n):
            if A[x][y] == 1 and d[y] == -1:
                d[y] = d[x] + 1
                f.append(y)
    return d


print(Distancias(6, 3))
