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

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

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

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

n = A("n")
e = B("e")
f = C("f")
l = D("l")
a = A("a")
d = D("d")
i = C("i")
g = D("g")
h = C("h")

n.s = h
n.q = h
n.p = e
n.w = e
e.y = f
f.u = l
f.v = l
f.w = h
f.r = n
l.p = e
l.r = f
a.s = h
a.p = e
a.w = e
a.q = f
d.p = e
d.r = i
i.u = g
i.v = l
i.w = h
i.r = a
g.p = e
g.r = h
h.u = d
h.v = g
h.w = f
h.r = a
assert h.r.q.w.u.p.y.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: B = None
        self.w: B = None
        self.q: C = None
        self.txt = txt

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

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

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

n = A("n")
e = B("e")
f = C("f")
l = D("l")
a = A("a")
d = D("d")
i = C("i")
g = D("g")
h = C("h")

n.s = h
n.q = h
n.p = e
n.w = e
e.y = f
f.u = l
f.v = l
f.w = h
f.r = n
l.p = e
l.r = f
a.s = h
a.p = e
a.w = e
a.q = f
d.p = e
d.r = i
i.u = g
i.v = l
i.w = h
i.r = a
g.p = e
g.r = h
h.u = d
h.v = g
h.w = f
h.r = a
assert h.r.q.w.u.p.y.w.r.txt == "a"