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

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

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

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

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

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

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

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

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