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

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

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

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

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

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

m.u = h
m.p = k
g.y = h
g.p = k
g.w = d
h.w = n
d.s = h
n.o = k
n.p = i
n.t = g
k.u = h
k.p = m
j.o = m
j.p = i
j.t = c
i.y = h
i.p = m
i.w = d
c.y = h
c.p = k
c.w = d
assert d.s.w.t.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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

m.u = h
m.p = k
g.y = h
g.p = k
g.w = d
h.w = n
d.s = h
n.o = k
n.p = i
n.t = g
k.u = h
k.p = m
j.o = m
j.p = i
j.t = c
i.y = h
i.p = m
i.w = d
c.y = h
c.p = k
c.w = d
assert d.s.w.t.p.p.txt == "m"