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

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

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

j = A("j")
e = B("e")
i = C("i")
l = B("l")

j.z = e
e.z = i
e.p = l
e.r = j
i.r = j
i.s = e
l.z = i
l.p = e
l.r = j
assert l.r.z.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

j = A("j")
e = B("e")
i = C("i")
l = B("l")

j.z = e
e.z = i
e.p = l
e.r = j
i.r = j
i.s = e
l.z = i
l.p = e
l.r = j
assert l.r.z.z.s.txt == "e"