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

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

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

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

l = A("l")
k = B("k")
i = C("i")
f = D("f")
e = B("e")
h = C("h")

l.y = f
l.p = f
k.q = h
k.s = f
k.v = e
i.z = e
i.p = f
f.w = k
f.p = k
f.x = e
e.q = h
e.s = f
e.v = k
h.z = k
h.p = f
assert k.s.x.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
i = C("i")
f = D("f")
e = B("e")
h = C("h")

l.y = f
l.p = f
k.q = h
k.s = f
k.v = e
i.z = e
i.p = f
f.w = k
f.p = k
f.x = e
e.q = h
e.s = f
e.v = k
h.z = k
h.p = f
assert k.s.x.v.v.v.txt == "k"