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

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

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

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

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

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

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

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

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

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

h.q = d
i.u = d
e.p = i
e.v = l
n.o = a
n.v = a
n.u = h
d.u = i
a.o = n
a.v = n
a.u = l
m.p = i
m.v = h
l.q = i
k.p = i
k.v = l
assert e.v.q.u.u.u.txt == "d"