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

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

f = A("f")
a = B("a")
l = A("l")
k = B("k")

f.u = l
a.z = k
l.u = f
k.z = a
assert f.u.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.z: B = None
        self.txt = txt

f = A("f")
a = B("a")
l = A("l")
k = B("k")

f.u = l
a.z = k
l.u = f
k.z = a
assert f.u.u.u.txt == "l"