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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
g = C("g")
m = D("m")
n = E("n")
h = B("h")
a = D("a")

c.p = m
c.u = h
f.x = a
f.r = g
f.u = c
f.w = c
g.o = h
g.p = c
g.w = f
m.o = n
m.s = f
n.o = c
h.x = m
h.r = g
h.u = c
h.w = c
a.o = n
a.s = h
assert m.o.o.p.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
g = C("g")
m = D("m")
n = E("n")
h = B("h")
a = D("a")

c.p = m
c.u = h
f.x = a
f.r = g
f.u = c
f.w = c
g.o = h
g.p = c
g.w = f
m.o = n
m.s = f
n.o = c
h.x = m
h.r = g
h.u = c
h.w = c
a.o = n
a.s = h
assert m.o.o.p.s.w.txt == "c"