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

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

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

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

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

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

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

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

b.q = e
b.x = f
f.v = e
f.r = b
e.r = f
e.s = f
e.q = b
assert b.q.s.r.txt == "b"