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

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

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

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

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

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

m.u = c
c.y = b
h.u = i
d.u = c
e.u = b
l.u = b
n.u = i
i.y = b
b.y = c
assert d.u.y.y.y.y.y.y.y.txt == "b"