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

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

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

e = A("e")
n = B("n")
m = C("m")
g = C("g")
l = B("l")
c = B("c")

e.z = l
e.w = m
n.z = e
m.u = e
g.u = e
l.z = e
c.z = e
assert c.z.w.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

e = A("e")
n = B("n")
m = C("m")
g = C("g")
l = B("l")
c = B("c")

e.z = l
e.w = m
n.z = e
m.u = e
g.u = e
l.z = e
c.z = e
assert c.z.w.u.w.u.txt == "e"