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

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

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

n = A("n")
h = B("h")
d = C("d")
l = C("l")
m = B("m")
b = C("b")
f = A("f")
k = A("k")
c = C("c")
i = C("i")

n.t = m
n.z = h
h.r = n
d.s = l
l.s = d
m.r = k
b.s = l
f.t = h
f.z = h
k.t = m
k.z = m
c.s = i
i.s = b
assert d.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
d = C("d")
l = C("l")
m = B("m")
b = C("b")
f = A("f")
k = A("k")
c = C("c")
i = C("i")

n.t = m
n.z = h
h.r = n
d.s = l
l.s = d
m.r = k
b.s = l
f.t = h
f.z = h
k.t = m
k.z = m
c.s = i
i.s = b
assert d.s.s.s.txt == "l"