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

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

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

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

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

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

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

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

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

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

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

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

h.r = d
b.y = k
b.s = e
b.z = e
b.r = a
k.s = d
k.z = d
k.r = a
k.t = h
a.r = j
a.z = j
a.q = k
a.s = b
g.p = j
g.t = n
g.r = e
g.w = b
j.r = a
j.z = a
j.q = d
j.s = b
d.s = k
d.z = k
d.r = j
d.t = n
e.y = d
e.s = b
e.z = b
e.r = j
n.r = d
assert n.r.r.s.s.z.r.q.r.q.txt == "k"