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

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

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

b = A("b")
m = B("m")
i = C("i")
n = C("n")

b.w = m
b.u = m
b.r = n
m.z = i
m.w = b
m.y = b
i.q = b
n.q = b
assert i.q.r.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: C = None
        self.u: B = None
        self.txt = txt

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

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

b = A("b")
m = B("m")
i = C("i")
n = C("n")

b.w = m
b.u = m
b.r = n
m.z = i
m.w = b
m.y = b
i.q = b
n.q = b
assert i.q.r.q.u.txt == "m"