class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: D = None
        self.t: D = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

a.q = i
a.u = i
a.w = i
a.r = n
a.t = n
i.t = j
i.x = l
i.z = a
i.s = g
j.v = n
j.p = a
n.z = j
n.o = a
m.q = l
l.z = j
l.o = a
g.t = j
g.x = n
g.z = a
g.s = i
assert l.z.p.t.o.t.o.r.txt == "n"