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

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

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

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

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

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

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

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

j.p = l
d.z = c
d.p = e
b.t = f
f.z = m
f.p = j
m.z = f
m.p = e
c.z = m
c.p = e
l.t = c
n.t = d
e.p = b
assert n.t.p.p.t.z.p.p.t.txt == "f"