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

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

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

k = A("k")
l = B("l")
b = C("b")
m = C("m")
e = B("e")

k.p = m
k.w = e
l.s = k
l.p = k
l.r = k
b.z = k
b.t = m
m.z = k
m.t = b
e.s = k
e.p = k
e.r = k
assert b.z.p.z.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: B = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
b = C("b")
m = C("m")
e = B("e")

k.p = m
k.w = e
l.s = k
l.p = k
l.r = k
b.z = k
b.t = m
m.z = k
m.t = b
e.s = k
e.p = k
e.r = k
assert b.z.p.z.p.t.txt == "b"