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

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

class C:
    def __init__(self, txt: str):
        self.v: E = None
        self.w: E = None
        self.u: D = None
        self.s: D = None
        self.z: E = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
j = C("j")
a = D("a")
l = E("l")
h = E("h")
d = A("d")
m = B("m")
e = D("e")

i.q = a
i.p = h
i.o = m
f.u = a
f.o = d
j.v = h
j.w = h
j.u = e
j.s = a
j.z = l
a.q = f
l.u = i
h.u = d
d.q = e
d.p = l
d.o = f
m.u = a
m.o = d
e.q = f
assert j.z.u.q.q.o.o.o.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.p: E = None
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: E = None
        self.w: E = None
        self.u: D = None
        self.s: D = None
        self.z: E = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
j = C("j")
a = D("a")
l = E("l")
h = E("h")
d = A("d")
m = B("m")
e = D("e")

i.q = a
i.p = h
i.o = m
f.u = a
f.o = d
j.v = h
j.w = h
j.u = e
j.s = a
j.z = l
a.q = f
l.u = i
h.u = d
d.q = e
d.p = l
d.o = f
m.u = a
m.o = d
e.q = f
assert j.z.u.q.q.o.o.o.o.u.txt == "a"