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

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

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

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

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

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

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

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

f.u = j
f.x = j
f.t = c
j.x = f
j.v = c
c.q = f
assert c.q.t.q.txt == "f"