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

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

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

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

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

b.o = m
k.p = d
f.z = k
n.s = l
n.t = l
n.o = f
n.p = a
h.z = k
d.z = k
l.s = n
l.t = n
l.o = f
l.p = h
a.z = k
m.o = b
assert l.o.z.p.z.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

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

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

b.o = m
k.p = d
f.z = k
n.s = l
n.t = l
n.o = f
n.p = a
h.z = k
d.z = k
l.s = n
l.t = n
l.o = f
l.p = h
a.z = k
m.o = b
assert l.o.z.p.z.p.z.p.txt == "d"