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

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

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

f = A("f")
a = B("a")
i = C("i")

f.q = a
f.u = i
a.u = f
a.t = f
i.q = f
assert a.t.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
i = C("i")

f.q = a
f.u = i
a.u = f
a.t = f
i.q = f
assert a.t.q.u.txt == "f"