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

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

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

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

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

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

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

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

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

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

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

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

k.w = a
i.u = m
i.v = a
i.y = e
n.x = m
n.y = m
n.p = e
n.w = j
j.w = n
g.y = m
g.p = k
g.o = d
d.w = a
m.u = i
m.v = a
m.y = g
e.y = m
e.p = k
e.o = k
c.w = a
a.w = c
assert m.y.p.w.txt == "a"