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

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

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

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

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

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

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