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

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

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

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

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

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

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

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

m.y = l
m.o = l
l.w = m
d.q = l
d.z = l
assert d.q.w.y.txt == "l"