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

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: B = None
        self.x: B = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.o: D = None
        self.x: C = None
        self.q: B = None
        self.txt = txt

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

j = A("j")
n = B("n")
l = C("l")
g = D("g")
h = E("h")
a = D("a")

j.r = a
n.v = a
l.z = j
l.q = j
l.s = j
l.v = n
l.x = n
g.u = a
g.o = a
g.p = l
g.x = l
g.q = n
h.o = g
h.p = a
h.v = j
h.y = j
h.s = n
a.u = g
a.o = g
a.p = l
a.x = l
a.q = n
assert h.s.v.q.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: B = None
        self.x: B = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.o: D = None
        self.x: C = None
        self.q: B = None
        self.txt = txt

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

j = A("j")
n = B("n")
l = C("l")
g = D("g")
h = E("h")
a = D("a")

j.r = a
n.v = a
l.z = j
l.q = j
l.s = j
l.v = n
l.x = n
g.u = a
g.o = a
g.p = l
g.x = l
g.q = n
h.o = g
h.p = a
h.v = j
h.y = j
h.s = n
a.u = g
a.o = g
a.p = l
a.x = l
a.q = n
assert h.s.v.q.v.x.txt == "l"