class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: C = None
        self.p: C = None
        self.w: D = None
        self.txt = txt

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

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

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

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

h = A("h")
d = B("d")
b = C("b")
g = D("g")
m = E("m")
e = D("e")
i = E("i")
n = B("n")

h.z = b
h.u = b
h.p = b
h.w = e
d.q = i
d.p = e
b.t = m
b.p = e
b.r = e
g.w = e
g.v = i
g.u = m
m.t = i
e.w = g
e.v = m
e.u = m
i.t = m
n.q = i
n.p = e
assert n.q.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: C = None
        self.p: C = None
        self.w: D = None
        self.txt = txt

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

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

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

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

h = A("h")
d = B("d")
b = C("b")
g = D("g")
m = E("m")
e = D("e")
i = E("i")
n = B("n")

h.z = b
h.u = b
h.p = b
h.w = e
d.q = i
d.p = e
b.t = m
b.p = e
b.r = e
g.w = e
g.v = i
g.u = m
m.t = i
e.w = g
e.v = m
e.u = m
i.t = m
n.q = i
n.p = e
assert n.q.t.t.t.t.t.txt == "m"