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

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

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

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

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

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

n.u = m
e.v = m
e.p = a
e.r = i
e.x = n
a.x = i
a.p = i
a.r = i
a.o = i
m.t = i
m.u = i
i.u = a
g.v = m
g.p = a
g.r = i
g.x = n
assert a.x.u.r.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

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

n.u = m
e.v = m
e.p = a
e.r = i
e.x = n
a.x = i
a.p = i
a.r = i
a.o = i
m.t = i
m.u = i
i.u = a
g.v = m
g.p = a
g.r = i
g.x = n
assert a.x.u.r.u.p.u.txt == "a"