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

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

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

d = A("d")
b = B("b")
f = C("f")

d.v = b
b.z = d
f.x = b
assert f.x.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
f = C("f")

d.v = b
b.z = d
f.x = b
assert f.x.z.v.txt == "b"