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

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

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

k = A("k")
f = B("f")
l = C("l")

k.v = l
f.q = l
f.z = k
l.s = k
l.o = k
assert k.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
l = C("l")

k.v = l
f.q = l
f.z = k
l.s = k
l.o = k
assert k.v.s.v.txt == "l"