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

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

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

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

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

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

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

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

b.w = e
e.r = m
e.t = m
m.q = b
assert b.w.t.q.txt == "b"