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.txt = txt

e = A("e")
g = B("g")
i = A("i")
a = A("a")
h = B("h")
l = A("l")
m = A("m")

e.s = g
g.s = h
i.s = h
a.s = h
h.s = g
l.s = g
m.s = h
assert m.s.s.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.txt = txt

e = A("e")
g = B("g")
i = A("i")
a = A("a")
h = B("h")
l = A("l")
m = A("m")

e.s = g
g.s = h
i.s = h
a.s = h
h.s = g
l.s = g
m.s = h
assert m.s.s.s.s.txt == "g"