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

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

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

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

d = A("d")
e = B("e")
h = C("h")
k = D("k")
j = A("j")
g = A("g")
n = D("n")
a = A("a")
m = C("m")

d.z = g
d.r = h
d.q = a
e.q = n
h.o = e
h.v = j
h.x = d
k.r = n
k.w = n
k.y = n
k.s = d
j.z = d
j.r = h
j.q = a
g.z = j
g.r = m
g.q = a
n.r = k
n.w = k
n.y = k
n.s = a
a.z = g
a.q = g
a.r = m
m.o = e
m.v = a
m.x = g
assert e.q.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: C = None
        self.q: A = None
        self.txt = txt

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

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

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

d = A("d")
e = B("e")
h = C("h")
k = D("k")
j = A("j")
g = A("g")
n = D("n")
a = A("a")
m = C("m")

d.z = g
d.r = h
d.q = a
e.q = n
h.o = e
h.v = j
h.x = d
k.r = n
k.w = n
k.y = n
k.s = d
j.z = d
j.r = h
j.q = a
g.z = j
g.r = m
g.q = a
n.r = k
n.w = k
n.y = k
n.s = a
a.z = g
a.q = g
a.r = m
m.o = e
m.v = a
m.x = g
assert e.q.r.w.txt == "n"