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

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

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

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

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

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

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

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

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