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

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

f = A("f")
j = B("j")
a = B("a")

f.z = a
j.u = f
a.u = f
assert j.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

f = A("f")
j = B("j")
a = B("a")

f.z = a
j.u = f
a.u = f
assert j.u.z.u.txt == "f"