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

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

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

class D:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: A = None
        self.v: E = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

n = A("n")
f = B("f")
e = C("e")
a = D("a")
m = E("m")
c = B("c")
d = B("d")
g = D("g")
i = C("i")

n.s = a
f.o = n
e.v = d
e.q = n
e.x = c
e.p = f
a.q = g
a.s = n
a.w = n
a.v = m
a.x = f
m.w = c
m.y = n
c.o = n
d.o = n
g.q = a
g.s = n
g.w = n
g.v = m
g.x = d
i.v = d
i.q = n
i.x = c
i.p = c
assert m.w.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: A = None
        self.v: E = None
        self.x: B = None
        self.w: A = None
        self.txt = txt

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

n = A("n")
f = B("f")
e = C("e")
a = D("a")
m = E("m")
c = B("c")
d = B("d")
g = D("g")
i = C("i")

n.s = a
f.o = n
e.v = d
e.q = n
e.x = c
e.p = f
a.q = g
a.s = n
a.w = n
a.v = m
a.x = f
m.w = c
m.y = n
c.o = n
d.o = n
g.q = a
g.s = n
g.w = n
g.v = m
g.x = d
i.v = d
i.q = n
i.x = c
i.p = c
assert m.w.o.s.txt == "a"