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

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

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

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

f.u = e
f.q = c
e.v = c
c.r = f
assert f.u.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: C = None
        self.txt = txt

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

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

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

f.u = e
f.q = c
e.v = c
c.r = f
assert f.u.v.r.txt == "f"