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

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

h = A("h")
m = B("m")
a = B("a")
l = B("l")
k = B("k")
n = A("n")

h.z = k
h.s = l
m.s = n
a.s = h
l.s = n
k.s = h
n.z = m
n.s = l
assert a.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

h = A("h")
m = B("m")
a = B("a")
l = B("l")
k = B("k")
n = A("n")

h.z = k
h.s = l
m.s = n
a.s = h
l.s = n
k.s = h
n.z = m
n.s = l
assert a.s.s.s.s.txt == "l"