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

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

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

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

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

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

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

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

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

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

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

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

a.s = g
a.z = d
m.o = n
d.w = m
d.v = b
d.p = a
g.x = k
g.q = n
k.u = g
k.v = b
k.q = j
k.s = a
j.s = h
j.z = d
n.w = m
n.v = b
n.p = j
b.u = h
b.v = k
b.q = a
b.s = a
h.x = b
h.q = d
assert m.o.p.s.txt == "h"