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

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

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

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

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

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

i.u = k
k.z = l
l.z = k
assert k.z.z.z.txt == "l"