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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

h.q = m
h.s = m
h.u = c
h.o = k
n.o = h
n.x = i
i.y = a
i.u = m
i.x = m
a.r = d
k.o = e
k.x = m
c.r = a
d.r = c
m.y = d
m.u = i
m.x = i
e.q = i
e.s = i
e.u = d
e.o = k
assert h.o.o.o.o.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: C = None
        self.u: D = None
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

h.q = m
h.s = m
h.u = c
h.o = k
n.o = h
n.x = i
i.y = a
i.u = m
i.x = m
a.r = d
k.o = e
k.x = m
c.r = a
d.r = c
m.y = d
m.u = i
m.x = i
e.q = i
e.s = i
e.u = d
e.o = k
assert h.o.o.o.o.s.y.txt == "a"