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

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

i = A("i")
n = B("n")
e = B("e")

i.u = e
n.w = i
e.w = i
assert i.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

i = A("i")
n = B("n")
e = B("e")

i.u = e
n.w = i
e.w = i
assert i.u.w.u.txt == "e"