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

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

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

b = A("b")
l = B("l")
m = C("m")
d = A("d")

b.w = d
l.y = m
l.u = b
l.w = d
m.q = b
d.w = b
assert l.u.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

b = A("b")
l = B("l")
m = C("m")
d = A("d")

b.w = d
l.y = m
l.u = b
l.w = d
m.q = b
d.w = b
assert l.u.w.w.txt == "b"