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

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

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

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

n.w = e
n.x = i
f.w = b
f.s = l
e.u = i
i.w = e
i.x = n
b.w = l
b.s = f
k.w = f
k.s = b
l.w = b
l.s = k
assert l.w.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: A = None
        self.txt = txt

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

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

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

n.w = e
n.x = i
f.w = b
f.s = l
e.u = i
i.w = e
i.x = n
b.w = l
b.s = f
k.w = f
k.s = b
l.w = b
l.s = k
assert l.w.w.s.w.txt == "f"