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

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

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

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

b.x = f
b.y = k
f.r = k
f.v = b
k.o = f
assert k.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: C = None
        self.txt = txt

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

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

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

b.x = f
b.y = k
f.r = k
f.v = b
k.o = f
assert k.o.r.o.txt == "f"