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

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

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

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

m = A("m")
i = B("i")
n = C("n")
j = D("j")
k = B("k")
l = B("l")
d = B("d")
f = D("f")
e = D("e")

m.s = k
i.s = m
i.x = k
i.w = n
n.o = d
n.q = f
j.s = n
j.z = m
k.s = m
k.x = i
k.w = n
l.s = m
l.x = d
l.w = n
d.s = m
d.x = k
d.w = n
f.s = n
f.z = m
e.s = n
e.z = m
assert k.s.s.x.x.s.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
n = C("n")
j = D("j")
k = B("k")
l = B("l")
d = B("d")
f = D("f")
e = D("e")

m.s = k
i.s = m
i.x = k
i.w = n
n.o = d
n.q = f
j.s = n
j.z = m
k.s = m
k.x = i
k.w = n
l.s = m
l.x = d
l.w = n
d.s = m
d.x = k
d.w = n
f.s = n
f.z = m
e.s = n
e.z = m
assert k.s.s.x.x.s.s.w.txt == "n"