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

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

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

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

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

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

n.r = h
n.o = i
n.q = g
n.t = m
n.x = e
h.o = a
i.x = e
i.v = e
i.t = e
i.p = a
e.w = g
e.v = n
g.o = i
m.o = a
j.r = m
j.o = i
j.q = g
j.t = a
j.x = e
a.o = m
assert h.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: C = None
        self.q: E = None
        self.t: B = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

n.r = h
n.o = i
n.q = g
n.t = m
n.x = e
h.o = a
i.x = e
i.v = e
i.t = e
i.p = a
e.w = g
e.v = n
g.o = i
m.o = a
j.r = m
j.o = i
j.q = g
j.t = a
j.x = e
a.o = m
assert h.o.o.o.o.o.o.txt == "m"