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

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

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

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

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

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

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

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

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

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

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

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

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