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

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

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

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

n = A("n")
i = B("i")
k = C("k")
c = D("c")
l = C("l")
f = C("f")
g = A("g")
a = D("a")
d = B("d")

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

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

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

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

n = A("n")
i = B("i")
k = C("k")
c = D("c")
l = C("l")
f = C("f")
g = A("g")
a = D("a")
d = B("d")

n.r = c
n.u = c
i.v = d
i.o = f
i.z = n
k.w = n
c.s = f
l.w = g
f.w = g
g.r = c
g.u = a
a.s = k
d.v = i
d.o = l
d.z = n
assert d.z.u.s.w.r.s.w.txt == "g"