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

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

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

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

g.s = e
m.w = f
m.x = e
m.p = a
e.o = c
e.p = a
c.s = e
a.s = e
l.s = e
n.o = l
n.p = g
f.w = m
f.x = n
f.p = c
assert c.s.o.s.o.s.o.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

g.s = e
m.w = f
m.x = e
m.p = a
e.o = c
e.p = a
c.s = e
a.s = e
l.s = e
n.o = l
n.p = g
f.w = m
f.x = n
f.p = c
assert c.s.o.s.o.s.o.s.p.txt == "a"