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

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

n = A("n")
e = B("e")
f = B("f")
a = A("a")
h = A("h")
b = B("b")
d = A("d")
m = B("m")
c = B("c")
i = B("i")

n.o = h
n.s = d
e.q = c
e.z = h
f.q = c
f.z = n
a.o = n
a.s = h
h.o = a
h.s = a
b.q = c
b.z = a
d.o = h
d.s = h
m.q = f
m.z = n
c.q = m
c.z = d
i.q = m
i.z = a
assert h.s.o.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.txt = txt

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

n = A("n")
e = B("e")
f = B("f")
a = A("a")
h = A("h")
b = B("b")
d = A("d")
m = B("m")
c = B("c")
i = B("i")

n.o = h
n.s = d
e.q = c
e.z = h
f.q = c
f.z = n
a.o = n
a.s = h
h.o = a
h.s = a
b.q = c
b.z = a
d.o = h
d.s = h
m.q = f
m.z = n
c.q = m
c.z = d
i.q = m
i.z = a
assert h.s.o.s.s.txt == "h"