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

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

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

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

d.v = m
d.p = m
h.u = c
h.o = e
h.r = m
a.s = e
a.p = d
k.s = a
k.p = m
e.s = k
e.p = m
m.v = d
m.p = d
n.u = h
n.o = a
n.r = m
c.u = n
c.o = k
c.r = m
assert n.u.o.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.p: A = None
        self.txt = txt

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

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

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

d.v = m
d.p = m
h.u = c
h.o = e
h.r = m
a.s = e
a.p = d
k.s = a
k.p = m
e.s = k
e.p = m
m.v = d
m.p = d
n.u = h
n.o = a
n.r = m
c.u = n
c.o = k
c.r = m
assert n.u.o.p.v.txt == "d"