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

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

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

l.y = i
m.t = i
e.y = l
i.y = e
b.t = e
k.t = e
n.t = e
h.t = l
d.t = i
assert m.t.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

l.y = i
m.t = i
e.y = l
i.y = e
b.t = e
k.t = e
n.t = e
h.t = l
d.t = i
assert m.t.y.y.y.y.txt == "e"