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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: A = None
        self.x: B = None
        self.r: D = None
        self.w: D = None
        self.txt = txt

a = A("a")
n = B("n")
e = C("e")
m = D("m")
d = E("d")

a.t = m
a.o = m
a.r = m
n.p = m
n.t = m
n.w = d
e.t = d
m.t = n
d.y = n
d.x = n
d.s = a
d.r = m
d.w = m
assert m.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.o: D = None
        self.r: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: A = None
        self.x: B = None
        self.r: D = None
        self.w: D = None
        self.txt = txt

a = A("a")
n = B("n")
e = C("e")
m = D("m")
d = E("d")

a.t = m
a.o = m
a.r = m
n.p = m
n.t = m
n.w = d
e.t = d
m.t = n
d.y = n
d.x = n
d.s = a
d.r = m
d.w = m
assert m.t.p.t.p.txt == "m"