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

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

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

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

a = A("a")
g = B("g")
m = C("m")
k = D("k")
n = D("n")
l = C("l")

a.q = n
g.w = l
m.s = g
m.w = k
k.s = l
k.z = g
n.s = m
n.z = g
l.s = g
l.w = k
assert g.w.w.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
m = C("m")
k = D("k")
n = D("n")
l = C("l")

a.q = n
g.w = l
m.s = g
m.w = k
k.s = l
k.z = g
n.s = m
n.z = g
l.s = g
l.w = k
assert g.w.w.z.w.w.txt == "k"