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

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

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: B = None
        self.z: B = None
        self.u: D = None
        self.txt = txt

n = A("n")
g = B("g")
m = C("m")
d = D("d")
c = D("c")

n.z = m
g.u = m
m.o = d
d.s = c
d.u = c
d.y = g
d.z = g
c.s = d
c.u = d
c.y = g
c.z = g
assert d.u.z.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: B = None
        self.z: B = None
        self.u: D = None
        self.txt = txt

n = A("n")
g = B("g")
m = C("m")
d = D("d")
c = D("c")

n.z = m
g.u = m
m.o = d
d.s = c
d.u = c
d.y = g
d.z = g
c.s = d
c.u = d
c.y = g
c.z = g
assert d.u.z.u.o.txt == "d"