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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: C = None
        self.t: A = None
        self.r: C = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
a = C("a")
n = D("n")
d = E("d")

m.q = n
m.y = a
m.t = k
m.r = d
k.p = m
k.t = m
k.y = a
k.r = a
a.s = d
a.v = k
n.s = d
d.r = k
d.s = n
d.w = a
d.q = a
assert n.s.s.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.y: C = None
        self.t: B = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.y: C = None
        self.t: A = None
        self.r: C = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
a = C("a")
n = D("n")
d = E("d")

m.q = n
m.y = a
m.t = k
m.r = d
k.p = m
k.t = m
k.y = a
k.r = a
a.s = d
a.v = k
n.s = d
d.r = k
d.s = n
d.w = a
d.q = a
assert n.s.s.s.w.txt == "a"