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

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

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

c = A("c")
i = B("i")
e = C("e")
b = B("b")
l = C("l")

c.s = l
i.x = c
i.z = l
e.p = c
e.z = b
b.x = c
b.z = e
l.p = c
l.z = b
assert b.x.s.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
e = C("e")
b = B("b")
l = C("l")

c.s = l
i.x = c
i.z = l
e.p = c
e.z = b
b.x = c
b.z = e
l.p = c
l.z = b
assert b.x.s.p.s.p.txt == "c"