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

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

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

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

l = A("l")
d = B("d")
n = C("n")
c = D("c")
e = B("e")
a = A("a")
k = A("k")
j = C("j")

l.o = c
l.s = d
d.v = j
n.z = j
n.o = d
n.p = d
c.q = e
c.y = e
e.v = n
a.o = c
a.s = d
k.o = c
k.s = e
j.z = n
j.o = e
j.p = d
assert k.s.v.o.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: B = None
        self.txt = txt

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

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

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

l = A("l")
d = B("d")
n = C("n")
c = D("c")
e = B("e")
a = A("a")
k = A("k")
j = C("j")

l.o = c
l.s = d
d.v = j
n.z = j
n.o = d
n.p = d
c.q = e
c.y = e
e.v = n
a.o = c
a.s = d
k.o = c
k.s = e
j.z = n
j.o = e
j.p = d
assert k.s.v.o.v.p.txt == "d"