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

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

m = A("m")
h = B("h")
b = C("b")
a = D("a")
f = B("f")
g = B("g")
i = D("i")
k = A("k")
e = A("e")

m.z = b
m.u = e
m.q = f
h.x = a
h.q = b
h.u = e
h.s = m
b.x = m
b.w = k
b.s = k
b.o = g
a.u = m
f.x = i
f.q = b
f.u = e
f.s = m
g.x = a
g.q = b
g.u = m
g.s = m
i.u = m
k.z = b
k.u = m
k.q = f
e.z = b
e.u = k
e.q = g
assert m.q.s.q.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: A = None
        self.q: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

m = A("m")
h = B("h")
b = C("b")
a = D("a")
f = B("f")
g = B("g")
i = D("i")
k = A("k")
e = A("e")

m.z = b
m.u = e
m.q = f
h.x = a
h.q = b
h.u = e
h.s = m
b.x = m
b.w = k
b.s = k
b.o = g
a.u = m
f.x = i
f.q = b
f.u = e
f.s = m
g.x = a
g.q = b
g.u = m
g.s = m
i.u = m
k.z = b
k.u = m
k.q = f
e.z = b
e.u = k
e.q = g
assert m.q.s.q.u.u.txt == "k"