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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

i.q = h
i.o = n
i.v = f
g.o = a
g.v = n
g.x = i
g.z = f
g.r = f
n.x = i
h.q = n
h.v = f
f.u = h
a.q = n
a.v = f
m.o = a
m.v = n
m.x = i
m.z = f
m.r = f
assert g.o.v.u.v.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: C = None
        self.v: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

i.q = h
i.o = n
i.v = f
g.o = a
g.v = n
g.x = i
g.z = f
g.r = f
n.x = i
h.q = n
h.v = f
f.u = h
a.q = n
a.v = f
m.o = a
m.v = n
m.x = i
m.z = f
m.r = f
assert g.o.v.u.v.u.v.u.txt == "h"