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

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

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

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

n.s = f
n.z = g
e.o = n
e.u = m
e.p = m
g.y = f
g.p = e
g.w = m
m.o = n
m.u = e
m.p = e
f.y = g
f.p = m
f.w = m
assert n.z.p.o.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: C = None
        self.txt = txt

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

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

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

n.s = f
n.z = g
e.o = n
e.u = m
e.p = m
g.y = f
g.p = e
g.w = m
m.o = n
m.u = e
m.p = e
f.y = g
f.p = m
f.w = m
assert n.z.p.o.s.y.txt == "g"