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

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

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

a = A("a")
b = B("b")
e = C("e")
m = A("m")
i = A("i")
d = A("d")

a.u = e
a.y = e
b.w = a
e.z = d
m.u = e
m.y = e
i.u = e
i.y = e
d.u = e
d.y = e
assert m.y.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: C = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
e = C("e")
m = A("m")
i = A("i")
d = A("d")

a.u = e
a.y = e
b.w = a
e.z = d
m.u = e
m.y = e
i.u = e
i.y = e
d.u = e
d.y = e
assert m.y.z.u.z.txt == "d"