class A:
    def __init__(self, txt: str):
        self.y: C = 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: D = None
        self.z: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: C = None
        self.txt = txt

m = A("m")
b = B("b")
l = C("l")
n = D("n")

m.y = l
b.w = m
l.q = n
l.z = n
n.w = b
n.x = l
assert n.w.w.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = 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: D = None
        self.z: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: C = None
        self.txt = txt

m = A("m")
b = B("b")
l = C("l")
n = D("n")

m.y = l
b.w = m
l.q = n
l.z = n
n.w = b
n.x = l
assert n.w.w.y.q.txt == "n"