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

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

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

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

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

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

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

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

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