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

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

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

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

h = A("h")
c = B("c")
a = C("a")
d = D("d")

h.w = c
h.x = a
h.q = d
h.o = d
c.o = d
c.x = d
a.t = d
a.w = d
a.z = c
d.u = h
d.y = a
d.x = c
assert a.z.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: C = None
        self.q: D = None
        self.o: D = None
        self.txt = txt

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

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

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

h = A("h")
c = B("c")
a = C("a")
d = D("d")

h.w = c
h.x = a
h.q = d
h.o = d
c.o = d
c.x = d
a.t = d
a.w = d
a.z = c
d.u = h
d.y = a
d.x = c
assert a.z.o.y.txt == "a"