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

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

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

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

n = A("n")
i = B("i")
k = C("k")
g = D("g")
f = A("f")
b = A("b")
l = C("l")
j = C("j")

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

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

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

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

n = A("n")
i = B("i")
k = C("k")
g = D("g")
f = A("f")
b = A("b")
l = C("l")
j = C("j")

n.w = f
n.s = g
i.v = g
i.r = g
i.z = j
k.r = b
k.z = g
g.q = n
g.w = i
g.o = i
g.u = j
f.w = b
f.s = g
b.w = f
b.s = g
l.r = n
l.z = g
j.r = f
j.z = g
assert g.u.z.o.z.r.s.q.w.txt == "f"