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

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

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.t: C = None
        self.x: C = None
        self.txt = txt

b = A("b")
m = B("m")
e = C("e")
h = D("h")

b.z = h
b.o = h
b.x = h
m.u = b
m.q = e
e.q = h
h.s = b
h.q = b
h.t = e
h.x = e
assert m.u.x.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.o: D = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.t: C = None
        self.x: C = None
        self.txt = txt

b = A("b")
m = B("m")
e = C("e")
h = D("h")

b.z = h
b.o = h
b.x = h
m.u = b
m.q = e
e.q = h
h.s = b
h.q = b
h.t = e
h.x = e
assert m.u.x.t.q.txt == "h"