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

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

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

l.x = k
k.u = e
e.x = k
assert k.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

l.x = k
k.u = e
e.x = k
assert k.u.x.u.txt == "e"