class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: E = None
        self.z: B = None
        self.q: E = None
        self.y: C = None
        self.txt = txt

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

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

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

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

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

h.s = f
h.z = f
h.p = n
h.q = n
h.y = c
f.o = c
f.x = m
c.s = m
c.u = h
c.q = k
m.q = h
m.z = h
m.v = k
n.p = c
n.q = m
k.o = j
k.x = m
j.s = m
j.u = h
j.q = k
assert m.v.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: E = None
        self.z: B = None
        self.q: E = None
        self.y: C = None
        self.txt = txt

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

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

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

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

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

h.s = f
h.z = f
h.p = n
h.q = n
h.y = c
f.o = c
f.x = m
c.s = m
c.u = h
c.q = k
m.q = h
m.z = h
m.v = k
n.p = c
n.q = m
k.o = j
k.x = m
j.s = m
j.u = h
j.q = k
assert m.v.o.s.txt == "m"