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

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

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

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

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

a.s = e
a.o = e
a.w = d
j.s = g
j.t = e
j.p = n
c.o = k
g.r = k
g.z = d
g.v = m
h.r = k
h.v = k
h.z = g
m.s = d
m.w = d
m.o = e
k.s = h
k.w = h
k.o = e
e.r = m
e.v = m
e.z = g
d.r = a
d.z = h
d.v = m
n.s = g
n.t = e
n.p = j
assert k.w.z.z.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.w: D = None
        self.o: D = None
        self.txt = txt

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

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

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

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

a.s = e
a.o = e
a.w = d
j.s = g
j.t = e
j.p = n
c.o = k
g.r = k
g.z = d
g.v = m
h.r = k
h.v = k
h.z = g
m.s = d
m.w = d
m.o = e
k.s = h
k.w = h
k.o = e
e.r = m
e.v = m
e.z = g
d.r = a
d.z = h
d.v = m
n.s = g
n.t = e
n.p = j
assert k.w.z.z.r.w.txt == "d"