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

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

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

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

m = A("m")
a = B("a")
d = C("d")
h = D("h")
b = B("b")

m.w = h
m.u = d
a.u = d
a.x = m
a.s = b
d.z = b
h.o = b
h.z = d
h.y = d
b.u = d
b.x = m
b.s = a
assert b.x.u.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.u: C = None
        self.txt = txt

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

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

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

m = A("m")
a = B("a")
d = C("d")
h = D("h")
b = B("b")

m.w = h
m.u = d
a.u = d
a.x = m
a.s = b
d.z = b
h.o = b
h.z = d
h.y = d
b.u = d
b.x = m
b.s = a
assert b.x.u.z.s.txt == "a"