class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

m = A("m")
c = B("c")
b = C("b")
n = D("n")
a = E("a")

m.p = a
c.t = m
c.s = a
c.p = a
c.q = a
b.u = a
b.t = c
n.u = a
a.s = b
a.t = m
assert m.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

m = A("m")
c = B("c")
b = C("b")
n = D("n")
a = E("a")

m.p = a
c.t = m
c.s = a
c.p = a
c.q = a
b.u = a
b.t = c
n.u = a
a.s = b
a.t = m
assert m.p.t.p.txt == "a"