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

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

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

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

b = A("b")
a = B("a")
h = C("h")
f = D("f")

b.w = a
b.o = f
a.q = f
a.u = f
h.z = f
f.w = h
f.z = h
f.p = a
assert a.u.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: D = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
h = C("h")
f = D("f")

b.w = a
b.o = f
a.q = f
a.u = f
h.z = f
f.w = h
f.z = h
f.p = a
assert a.u.z.z.z.txt == "h"