class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

i = A("i")
g = B("g")
l = A("l")
b = B("b")
n = A("n")
d = A("d")

i.z = l
i.y = d
g.u = b
l.z = d
l.y = i
b.u = g
n.z = i
n.y = l
d.z = n
d.y = i
assert d.y.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

i = A("i")
g = B("g")
l = A("l")
b = B("b")
n = A("n")
d = A("d")

i.z = l
i.y = d
g.u = b
l.z = d
l.y = i
b.u = g
n.z = i
n.y = l
d.z = n
d.y = i
assert d.y.y.z.txt == "n"