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

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

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

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

l.u = j
l.z = e
e.x = l
j.s = l
assert l.u.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

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

l.u = j
l.z = e
e.x = l
j.s = l
assert l.u.s.z.txt == "e"