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

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

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

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

m.w = e
b.t = m
b.q = m
b.x = e
e.w = m
e.v = b
assert e.w.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

m.w = e
b.t = m
b.q = m
b.x = e
e.w = m
e.v = b
assert e.w.w.v.txt == "b"