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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.x: A = None
        self.w: A = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.x: A = None
        self.w: A = None
        self.txt = txt

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

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

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

d.q = j
d.r = j
d.v = a
j.x = g
j.q = a
j.o = a
j.w = m
m.s = g
m.o = d
m.x = d
m.w = d
a.t = g
a.q = m
a.x = m
a.s = j
g.x = a
n.x = g
n.q = a
n.o = a
n.w = m
assert m.w.v.s.w.w.v.txt == "a"