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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.v: E = None
        self.z: E = None
        self.txt = txt

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

k.q = i
f.o = k
f.y = n
f.q = g
n.v = j
g.u = h
g.s = h
g.r = i
g.w = m
m.q = k
m.r = f
m.v = j
m.z = j
i.u = k
i.s = h
i.r = g
i.w = j
j.q = h
j.r = a
j.v = m
j.z = m
a.o = k
a.y = n
a.q = g
h.q = g
assert i.u.q.s.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: B = None
        self.v: E = None
        self.z: E = None
        self.txt = txt

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

k.q = i
f.o = k
f.y = n
f.q = g
n.v = j
g.u = h
g.s = h
g.r = i
g.w = m
m.q = k
m.r = f
m.v = j
m.z = j
i.u = k
i.s = h
i.r = g
i.w = j
j.q = h
j.r = a
j.v = m
j.z = m
a.o = k
a.y = n
a.q = g
h.q = g
assert i.u.q.s.q.r.txt == "i"