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

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

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

c = A("c")
e = B("e")
m = C("m")
f = C("f")
i = A("i")
h = B("h")
b = A("b")

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

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

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

c = A("c")
e = B("e")
m = C("m")
f = C("f")
i = A("i")
h = B("h")
b = A("b")

c.t = m
c.z = m
c.p = f
e.t = h
e.z = i
m.z = h
f.z = e
i.t = f
i.p = f
i.z = m
h.t = e
h.z = b
b.t = f
b.p = m
b.z = m
assert c.p.z.t.z.p.z.z.txt == "b"