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

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

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

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

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

n = A("n")
g = B("g")
h = C("h")
a = D("a")
i = E("i")
c = A("c")
m = B("m")

n.s = g
g.x = h
g.u = a
g.z = a
g.y = m
h.o = a
h.t = i
h.p = n
a.o = g
a.q = g
a.v = h
i.o = h
c.s = g
m.x = h
m.u = a
m.z = a
m.y = g
assert m.x.t.o.t.o.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

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

n = A("n")
g = B("g")
h = C("h")
a = D("a")
i = E("i")
c = A("c")
m = B("m")

n.s = g
g.x = h
g.u = a
g.z = a
g.y = m
h.o = a
h.t = i
h.p = n
a.o = g
a.q = g
a.v = h
i.o = h
c.s = g
m.x = h
m.u = a
m.z = a
m.y = g
assert m.x.t.o.t.o.o.v.txt == "h"