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

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

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

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

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

a.z = m
a.r = h
a.w = f
e.t = g
e.s = g
e.z = f
f.w = j
f.q = g
h.w = a
h.u = a
h.r = g
h.q = f
d.w = j
d.q = g
g.w = a
g.u = a
g.r = h
g.q = n
m.t = g
m.s = h
m.z = f
j.t = h
j.s = h
j.z = d
n.w = e
n.q = h
assert j.t.u.w.q.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: D = None
        self.w: C = None
        self.txt = txt

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

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

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

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

a.z = m
a.r = h
a.w = f
e.t = g
e.s = g
e.z = f
f.w = j
f.q = g
h.w = a
h.u = a
h.r = g
h.q = f
d.w = j
d.q = g
g.w = a
g.u = a
g.r = h
g.q = n
m.t = g
m.s = h
m.z = f
j.t = h
j.s = h
j.z = d
n.w = e
n.q = h
assert j.t.u.w.q.r.r.r.txt == "h"