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

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

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

j = A("j")
f = B("f")
c = C("c")

j.t = c
f.r = j
c.q = f
c.o = f
assert f.r.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
c = C("c")

j.t = c
f.r = j
c.q = f
c.o = f
assert f.r.t.o.txt == "f"