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

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: D = None
        self.x: E = None
        self.q: D = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
m = C("m")
c = D("c")
b = E("b")
a = B("a")
j = E("j")
d = B("d")
f = C("f")

n.q = c
e.x = n
e.y = d
e.z = f
m.v = f
m.p = c
m.q = c
m.x = j
c.z = m
b.w = m
b.r = m
b.x = c
b.q = j
a.x = n
a.y = e
a.z = m
j.w = m
j.r = m
j.x = c
j.q = b
d.x = n
d.y = e
d.z = f
f.v = m
f.p = c
f.q = c
f.x = b
assert d.x.q.z.x.w.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: D = None
        self.x: E = None
        self.q: D = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
m = C("m")
c = D("c")
b = E("b")
a = B("a")
j = E("j")
d = B("d")
f = C("f")

n.q = c
e.x = n
e.y = d
e.z = f
m.v = f
m.p = c
m.q = c
m.x = j
c.z = m
b.w = m
b.r = m
b.x = c
b.q = j
a.x = n
a.y = e
a.z = m
j.w = m
j.r = m
j.x = c
j.q = b
d.x = n
d.y = e
d.z = f
f.v = m
f.p = c
f.q = c
f.x = b
assert d.x.q.z.x.w.p.z.txt == "m"