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

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

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

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

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

f = A("f")
m = B("m")
b = C("b")
h = D("h")
e = E("e")
k = C("k")
g = C("g")
c = A("c")
n = E("n")
a = E("a")

f.p = m
m.u = h
b.x = n
b.s = h
h.v = f
h.q = b
e.s = a
k.x = n
k.s = h
g.x = n
g.s = h
c.p = m
n.s = e
a.s = e
assert a.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

f = A("f")
m = B("m")
b = C("b")
h = D("h")
e = E("e")
k = C("k")
g = C("g")
c = A("c")
n = E("n")
a = E("a")

f.p = m
m.u = h
b.x = n
b.s = h
h.v = f
h.q = b
e.s = a
k.x = n
k.s = h
g.x = n
g.s = h
c.p = m
n.s = e
a.s = e
assert a.s.s.s.s.s.txt == "e"