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

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

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

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

l.v = j
j.o = l
m.z = j
m.x = l
assert l.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

l.v = j
j.o = l
m.z = j
m.x = l
assert l.v.o.v.txt == "j"