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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
j = C("j")
n = D("n")
m = E("m")
e = A("e")

b.t = h
h.r = m
h.o = n
h.w = n
h.x = n
h.p = n
j.v = h
n.p = b
n.v = m
m.r = j
m.p = j
e.t = h
assert m.p.v.r.r.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
j = C("j")
n = D("n")
m = E("m")
e = A("e")

b.t = h
h.r = m
h.o = n
h.w = n
h.x = n
h.p = n
j.v = h
n.p = b
n.v = m
m.r = j
m.p = j
e.t = h
assert m.p.v.r.r.v.w.txt == "n"