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

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

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

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

c = A("c")
n = B("n")
k = C("k")
d = D("d")
i = A("i")
l = B("l")
f = D("f")
m = D("m")
h = A("h")
e = A("e")

c.w = n
n.p = d
n.v = d
k.o = i
k.v = e
d.v = l
i.w = n
l.p = d
l.v = d
f.v = n
m.v = l
h.w = l
e.w = l
assert d.v.v.v.v.v.p.v.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

c = A("c")
n = B("n")
k = C("k")
d = D("d")
i = A("i")
l = B("l")
f = D("f")
m = D("m")
h = A("h")
e = A("e")

c.w = n
n.p = d
n.v = d
k.o = i
k.v = e
d.v = l
i.w = n
l.p = d
l.v = d
f.v = n
m.v = l
h.w = l
e.w = l
assert d.v.v.v.v.v.p.v.p.v.p.txt == "d"