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

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

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

n = A("n")
l = B("l")
i = C("i")
b = C("b")
d = B("d")
k = C("k")
c = C("c")
f = A("f")

n.w = d
l.z = b
l.s = c
i.s = b
i.r = f
b.s = c
b.r = n
d.z = i
d.s = i
k.s = i
k.r = f
c.s = k
c.r = n
f.w = l
assert f.w.s.s.s.r.w.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
i = C("i")
b = C("b")
d = B("d")
k = C("k")
c = C("c")
f = A("f")

n.w = d
l.z = b
l.s = c
i.s = b
i.r = f
b.s = c
b.r = n
d.z = i
d.s = i
k.s = i
k.r = f
c.s = k
c.r = n
f.w = l
assert f.w.s.s.s.r.w.z.s.txt == "c"