class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

l = A("l")
e = B("e")
g = C("g")
b = D("b")
h = C("h")

l.v = b
e.o = g
g.p = e
b.w = e
b.r = e
b.o = e
b.z = g
h.p = e
assert h.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

l = A("l")
e = B("e")
g = C("g")
b = D("b")
h = C("h")

l.v = b
e.o = g
g.p = e
b.w = e
b.r = e
b.o = e
b.z = g
h.p = e
assert h.p.o.p.txt == "e"