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

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

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

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

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

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

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

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

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

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

d.v = i
d.q = m
n.o = c
n.p = d
n.s = h
c.p = j
j.z = i
h.v = e
h.q = m
m.o = i
m.p = h
m.s = h
e.p = j
i.p = j
k.v = c
k.q = n
a.z = c
assert c.p.z.p.z.p.txt == "j"