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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: C = None
        self.u: D = None
        self.txt = txt

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

e = A("e")
d = B("d")
i = C("i")
k = D("k")
m = C("m")
h = B("h")
b = D("b")

e.p = b
d.t = h
i.t = k
i.u = k
i.y = m
k.t = m
k.r = m
k.p = e
k.w = i
m.t = b
m.u = b
m.y = i
h.t = d
b.t = m
b.r = m
b.w = m
b.p = e
assert m.t.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: C = None
        self.u: D = None
        self.txt = txt

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

e = A("e")
d = B("d")
i = C("i")
k = D("k")
m = C("m")
h = B("h")
b = D("b")

e.p = b
d.t = h
i.t = k
i.u = k
i.y = m
k.t = m
k.r = m
k.p = e
k.w = i
m.t = b
m.u = b
m.y = i
h.t = d
b.t = m
b.r = m
b.w = m
b.p = e
assert m.t.p.p.p.p.txt == "b"