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

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

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

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

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

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

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

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

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

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

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

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

h.t = a
h.s = c
h.p = b
h.u = b
n.s = b
n.w = h
c.s = a
b.t = n
b.x = n
b.p = c
b.s = c
b.u = a
a.q = n
assert n.w.t.q.s.x.txt == "n"