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

f = A("f")
k = B("k")
e = A("e")

f.u = e
k.y = e
e.u = f
assert k.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

f = A("f")
k = B("k")
e = A("e")

f.u = e
k.y = e
e.u = f
assert k.y.u.u.txt == "e"