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

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

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

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

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

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

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

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

d.p = i
i.o = f
f.v = d
f.z = d
assert i.o.v.p.txt == "i"