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

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

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

j = A("j")
n = B("n")
h = C("h")
l = C("l")
e = A("e")
m = C("m")
a = A("a")
d = B("d")

j.q = d
j.s = m
j.v = l
n.v = m
n.r = d
h.u = a
h.x = n
h.r = m
l.u = a
l.x = d
l.r = m
e.q = d
e.s = m
e.v = l
m.u = e
m.x = n
m.r = l
a.q = n
a.s = m
a.v = l
d.v = l
d.r = n
assert l.u.s.x.v.u.s.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.v: C = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
h = C("h")
l = C("l")
e = A("e")
m = C("m")
a = A("a")
d = B("d")

j.q = d
j.s = m
j.v = l
n.v = m
n.r = d
h.u = a
h.x = n
h.r = m
l.u = a
l.x = d
l.r = m
e.q = d
e.s = m
e.v = l
m.u = e
m.x = n
m.r = l
a.q = n
a.s = m
a.v = l
d.v = l
d.r = n
assert l.u.s.x.v.u.s.x.r.txt == "d"