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

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

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

a = A("a")
l = B("l")
m = C("m")
e = B("e")

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

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

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

a = A("a")
l = B("l")
m = C("m")
e = B("e")

a.z = m
a.p = m
l.p = e
l.w = a
m.t = a
m.s = l
e.p = l
e.w = a
assert m.t.p.s.p.txt == "e"