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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.p: D = None
        self.t: E = None
        self.txt = txt

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

n.v = l
n.u = a
n.q = h
n.w = d
h.q = a
l.u = a
l.v = a
l.s = n
f.w = g
f.z = n
g.x = h
g.r = h
g.p = d
g.t = m
d.w = g
d.z = n
a.v = l
a.u = n
a.q = h
a.w = d
m.x = h
m.r = h
m.p = f
m.t = g
assert g.p.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: A = None
        self.q: B = None
        self.w: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.p: D = None
        self.t: E = None
        self.txt = txt

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

n.v = l
n.u = a
n.q = h
n.w = d
h.q = a
l.u = a
l.v = a
l.s = n
f.w = g
f.z = n
g.x = h
g.r = h
g.p = d
g.t = m
d.w = g
d.z = n
a.v = l
a.u = n
a.q = h
a.w = d
m.x = h
m.r = h
m.p = f
m.t = g
assert g.p.z.q.txt == "h"