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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: A = None
        self.t: A = None
        self.u: C = None
        self.txt = txt

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

h.o = m
h.v = n
a.p = g
n.r = a
n.t = a
n.u = g
n.q = h
g.y = n
m.v = g
m.r = h
m.t = h
m.u = n
assert n.u.y.q.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.v: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: A = None
        self.t: A = None
        self.u: C = None
        self.txt = txt

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

h.o = m
h.v = n
a.p = g
n.r = a
n.t = a
n.u = g
n.q = h
g.y = n
m.v = g
m.r = h
m.t = h
m.u = n
assert n.u.y.q.o.u.txt == "n"