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

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

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

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

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

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

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

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

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

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

m.y = e
m.t = a
b.r = m
b.v = i
b.q = e
a.s = m
a.t = e
e.x = a
e.u = b
i.r = m
i.v = b
i.q = e
assert e.x.s.t.txt == "a"