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

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

n = A("n")
d = B("d")
k = B("k")
c = B("c")
m = A("m")
e = B("e")
h = A("h")
j = B("j")
g = A("g")
b = B("b")

n.o = c
d.z = g
d.s = h
k.z = n
k.s = h
c.z = m
c.s = n
m.o = c
e.z = m
e.s = n
h.o = b
j.z = g
j.s = m
g.o = d
b.z = m
b.s = h
assert h.o.z.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

n = A("n")
d = B("d")
k = B("k")
c = B("c")
m = A("m")
e = B("e")
h = A("h")
j = B("j")
g = A("g")
b = B("b")

n.o = c
d.z = g
d.s = h
k.z = n
k.s = h
c.z = m
c.s = n
m.o = c
e.z = m
e.s = n
h.o = b
j.z = g
j.s = m
g.o = d
b.z = m
b.s = h
assert h.o.z.o.s.txt == "n"