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

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

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

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

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

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

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

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

f.q = g
f.r = e
f.s = e
g.w = f
g.u = f
e.r = f
assert e.r.q.u.txt == "f"