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

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

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

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

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

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

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

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

k.o = f
b.q = k
b.v = k
f.t = k
assert k.o.t.o.txt == "f"