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

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

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

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

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

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

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

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

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

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

d.u = e
d.v = e
d.s = n
d.r = m
g.s = e
g.w = j
a.v = n
m.o = a
m.u = a
m.v = a
m.z = g
i.o = a
i.u = a
i.v = a
i.z = k
k.s = e
k.w = i
j.o = a
j.u = a
j.v = a
j.z = g
n.s = d
n.w = j
e.u = d
e.v = d
e.s = k
e.r = m
assert i.u.v.w.u.v.s.s.w.txt == "j"