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

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

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

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

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

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

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

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

f.o = d
f.z = d
d.r = f
h.v = d
assert h.v.r.z.txt == "d"