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

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

class C:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: D = None
        self.txt = txt

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

e = A("e")
d = B("d")
n = C("n")
f = D("f")
j = C("j")
h = B("h")
m = A("m")
b = C("b")
a = A("a")

e.w = j
e.y = d
d.w = f
d.o = h
n.z = j
n.o = f
f.t = e
f.r = e
f.p = b
f.q = h
j.z = b
j.o = f
h.w = f
h.o = d
m.w = j
m.y = d
b.z = n
b.o = f
a.w = b
a.y = d
assert m.y.o.w.p.z.o.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: D = None
        self.txt = txt

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

e = A("e")
d = B("d")
n = C("n")
f = D("f")
j = C("j")
h = B("h")
m = A("m")
b = C("b")
a = A("a")

e.w = j
e.y = d
d.w = f
d.o = h
n.z = j
n.o = f
f.t = e
f.r = e
f.p = b
f.q = h
j.z = b
j.o = f
h.w = f
h.o = d
m.w = j
m.y = d
b.z = n
b.o = f
a.w = b
a.y = d
assert m.y.o.w.p.z.o.q.w.q.txt == "h"