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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: C = None
        self.z: E = None
        self.t: A = None
        self.y: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

m = A("m")
i = B("i")
n = C("n")
k = D("k")
d = E("d")

m.t = k
m.s = d
i.p = n
i.x = n
i.z = d
i.t = m
i.y = m
n.s = k
k.z = n
k.t = i
k.w = i
d.r = n
assert n.s.w.x.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: C = None
        self.z: E = None
        self.t: A = None
        self.y: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

m = A("m")
i = B("i")
n = C("n")
k = D("k")
d = E("d")

m.t = k
m.s = d
i.p = n
i.x = n
i.z = d
i.t = m
i.y = m
n.s = k
k.z = n
k.t = i
k.w = i
d.r = n
assert n.s.w.x.s.z.txt == "n"