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

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

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

m = A("m")
h = B("h")
j = C("j")
e = B("e")
b = A("b")
f = B("f")
n = C("n")
d = B("d")
l = B("l")

m.p = l
h.t = m
j.s = h
j.p = n
j.t = l
e.t = b
b.p = h
f.t = b
n.s = l
n.t = l
n.p = j
d.t = m
l.t = m
assert f.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
j = C("j")
e = B("e")
b = A("b")
f = B("f")
n = C("n")
d = B("d")
l = B("l")

m.p = l
h.t = m
j.s = h
j.p = n
j.t = l
e.t = b
b.p = h
f.t = b
n.s = l
n.t = l
n.p = j
d.t = m
l.t = m
assert f.t.p.t.p.txt == "l"