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

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

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

l.y = a
e.u = l
a.y = h
h.y = l
k.u = l
m.u = h
assert e.u.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.u: A = None
        self.txt = txt

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

l.y = a
e.u = l
a.y = h
h.y = l
k.u = l
m.u = h
assert e.u.y.y.y.y.txt == "a"