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

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

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

a = A("a")
l = B("l")
b = C("b")

a.v = l
l.y = b
l.x = a
l.r = a
b.z = l
assert l.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
b = C("b")

a.v = l
l.y = b
l.x = a
l.r = a
b.z = l
assert l.y.z.y.txt == "b"