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

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

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

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

f = A("f")
a = B("a")
n = C("n")
i = D("i")
m = D("m")
e = B("e")

f.p = e
a.s = f
a.w = f
a.p = f
n.q = f
n.o = f
n.u = f
n.t = a
i.t = a
i.z = n
i.p = m
m.t = e
m.z = n
m.p = i
e.s = f
e.w = f
e.p = f
assert m.t.s.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
n = C("n")
i = D("i")
m = D("m")
e = B("e")

f.p = e
a.s = f
a.w = f
a.p = f
n.q = f
n.o = f
n.u = f
n.t = a
i.t = a
i.z = n
i.p = m
m.t = e
m.z = n
m.p = i
e.s = f
e.w = f
e.p = f
assert m.t.s.p.s.p.txt == "e"