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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

f.p = g
f.w = g
c.o = h
c.u = k
b.p = k
b.t = d
g.o = m
d.t = l
a.p = k
a.t = d
l.t = d
m.p = c
m.t = d
k.o = b
k.u = c
h.p = c
h.t = d
assert m.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

f.p = g
f.w = g
c.o = h
c.u = k
b.p = k
b.t = d
g.o = m
d.t = l
a.p = k
a.t = d
l.t = d
m.p = c
m.t = d
k.o = b
k.u = c
h.p = c
h.t = d
assert m.t.t.t.t.t.txt == "d"