class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: D = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

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

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

m.w = j
m.q = d
m.r = n
a.z = n
g.q = m
d.u = g
d.p = g
d.x = k
d.z = j
d.t = a
n.y = d
n.o = c
n.q = k
c.u = g
c.p = g
c.x = k
c.z = m
c.t = a
j.w = m
j.q = d
j.r = n
k.z = n
assert n.o.z.q.p.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: D = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

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

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

m.w = j
m.q = d
m.r = n
a.z = n
g.q = m
d.u = g
d.p = g
d.x = k
d.z = j
d.t = a
n.y = d
n.o = c
n.q = k
c.u = g
c.p = g
c.x = k
c.z = m
c.t = a
j.w = m
j.q = d
j.r = n
k.z = n
assert n.o.z.q.p.q.w.txt == "j"