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

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

c = A("c")
f = B("f")
n = A("n")

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

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

c = A("c")
f = B("f")
n = A("n")

c.z = f
f.w = c
f.u = n
n.z = f
assert n.z.u.z.txt == "f"