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

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
m = C("m")
g = D("g")
n = E("n")
i = B("i")
b = C("b")
h = D("h")
d = E("d")
f = D("f")

j.p = c
c.r = m
m.u = n
g.y = j
g.o = m
g.p = m
g.w = h
n.p = d
n.w = m
i.r = m
b.u = n
h.y = j
h.o = m
h.p = b
h.w = f
d.p = n
d.w = m
f.y = j
f.o = m
f.p = b
f.w = g
assert f.w.w.p.u.p.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
m = C("m")
g = D("g")
n = E("n")
i = B("i")
b = C("b")
h = D("h")
d = E("d")
f = D("f")

j.p = c
c.r = m
m.u = n
g.y = j
g.o = m
g.p = m
g.w = h
n.p = d
n.w = m
i.r = m
b.u = n
h.y = j
h.o = m
h.p = b
h.w = f
d.p = n
d.w = m
f.y = j
f.o = m
f.p = b
f.w = g
assert f.w.w.p.u.p.w.u.w.txt == "m"