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

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

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

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

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

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

d.q = h
d.x = k
b.w = n
b.t = d
b.z = h
j.p = g
g.o = a
g.x = a
g.q = d
g.z = e
g.w = k
a.w = h
a.x = k
n.q = j
n.x = k
e.q = j
e.x = k
c.w = d
c.t = e
c.z = j
k.o = a
k.x = a
k.q = d
k.z = n
k.w = g
h.p = g
assert g.z.q.p.w.z.q.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

d.q = h
d.x = k
b.w = n
b.t = d
b.z = h
j.p = g
g.o = a
g.x = a
g.q = d
g.z = e
g.w = k
a.w = h
a.x = k
n.q = j
n.x = k
e.q = j
e.x = k
c.w = d
c.t = e
c.z = j
k.o = a
k.x = a
k.q = d
k.z = n
k.w = g
h.p = g
assert g.z.q.p.w.z.q.p.w.txt == "k"