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

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

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

h.y = i
l.s = h
e.s = h
i.y = h
m.s = i
n.s = h
d.s = i
k.s = i
assert h.y.y.y.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.s: A = None
        self.txt = txt

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

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