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

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

e = A("e")
f = B("f")
i = B("i")
m = A("m")
l = A("l")
h = A("h")
k = B("k")

e.t = m
f.s = m
f.o = e
i.s = e
i.o = l
m.t = l
l.t = e
h.t = m
k.s = l
k.o = l
assert m.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

e = A("e")
f = B("f")
i = B("i")
m = A("m")
l = A("l")
h = A("h")
k = B("k")

e.t = m
f.s = m
f.o = e
i.s = e
i.o = l
m.t = l
l.t = e
h.t = m
k.s = l
k.o = l
assert m.t.t.t.t.txt == "l"