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

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

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

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

a = A("a")
b = B("b")
n = C("n")
h = D("h")
l = B("l")

a.z = n
a.y = l
b.q = n
b.p = n
n.s = b
h.x = a
h.w = n
l.q = n
l.p = n
assert a.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
n = C("n")
h = D("h")
l = B("l")

a.z = n
a.y = l
b.q = n
b.p = n
n.s = b
h.x = a
h.w = n
l.q = n
l.p = n
assert a.z.s.q.txt == "n"