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

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: A = None
        self.txt = txt

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

f.u = h
f.v = h
f.s = e
h.x = e
h.v = e
h.s = e
h.w = a
n.q = f
e.w = h
e.z = a
l.u = h
l.v = h
l.s = e
i.q = l
a.u = h
a.v = h
a.s = e
assert n.q.s.z.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: D = None
        self.v: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: A = None
        self.txt = txt

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

f.u = h
f.v = h
f.s = e
h.x = e
h.v = e
h.s = e
h.w = a
n.q = f
e.w = h
e.z = a
l.u = h
l.v = h
l.s = e
i.q = l
a.u = h
a.v = h
a.s = e
assert n.q.s.z.s.w.txt == "h"