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

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

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

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

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

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

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

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

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