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

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

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

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

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

b.t = i
a.u = i
a.s = i
a.w = e
a.q = b
e.x = a
e.s = m
i.z = d
i.r = a
i.p = b
m.x = a
m.s = e
d.u = i
d.s = i
d.w = e
d.q = b
assert e.x.w.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

b.t = i
a.u = i
a.s = i
a.w = e
a.q = b
e.x = a
e.s = m
i.z = d
i.r = a
i.p = b
m.x = a
m.s = e
d.u = i
d.s = i
d.w = e
d.q = b
assert e.x.w.s.x.txt == "a"