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

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

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

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

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

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

c.r = i
c.t = a
c.q = n
m.w = n
m.q = l
a.r = l
a.y = l
a.x = c
a.s = c
a.v = m
n.w = m
n.t = m
n.u = a
n.v = l
n.z = c
l.w = n
i.r = c
i.t = a
i.q = n
assert n.v.w.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: C = None
        self.q: D = None
        self.txt = txt

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

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

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

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

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

c.r = i
c.t = a
c.q = n
m.w = n
m.q = l
a.r = l
a.y = l
a.x = c
a.s = c
a.v = m
n.w = m
n.t = m
n.u = a
n.v = l
n.z = c
l.w = n
i.r = c
i.t = a
i.q = n
assert n.v.w.z.q.txt == "n"