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

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

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

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

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

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

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

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

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

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

h.s = n
h.u = n
h.r = k
m.v = a
m.u = k
m.o = j
d.t = k
d.u = h
d.v = j
d.p = n
a.s = m
i.t = m
i.u = n
i.v = j
i.p = h
n.s = h
n.u = h
n.r = m
j.v = a
j.u = k
j.o = m
k.v = a
k.u = m
k.o = m
assert k.v.s.v.s.u.o.txt == "m"