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

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

n = A("n")
i = B("i")
a = A("a")
h = B("h")

n.y = a
i.u = h
a.y = n
h.u = i
assert i.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

n = A("n")
i = B("i")
a = A("a")
h = B("h")

n.y = a
i.u = h
a.y = n
h.u = i
assert i.u.u.u.u.txt == "i"