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

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

n = A("n")
h = B("h")
c = A("c")
b = B("b")
e = B("e")

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

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

n = A("n")
h = B("h")
c = A("c")
b = B("b")
e = B("e")

n.u = c
h.y = n
c.u = n
b.y = c
e.y = n
assert b.y.u.u.txt == "c"