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

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

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

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

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

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

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