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

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

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

e = A("e")
n = B("n")
i = C("i")
f = C("f")

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

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

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

e = A("e")
n = B("n")
i = C("i")
f = C("f")

e.x = n
n.z = e
n.o = i
i.v = f
i.s = e
i.z = e
f.v = i
f.s = e
f.z = e
assert n.o.v.z.x.txt == "n"