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

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

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

k = A("k")
l = B("l")
a = C("a")
c = A("c")
e = A("e")
f = C("f")
i = C("i")

k.w = l
k.s = c
l.x = i
a.w = c
c.w = l
c.s = k
e.w = l
e.s = k
f.w = k
i.w = e
assert e.w.x.w.s.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: A = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
a = C("a")
c = A("c")
e = A("e")
f = C("f")
i = C("i")

k.w = l
k.s = c
l.x = i
a.w = c
c.w = l
c.s = k
e.w = l
e.s = k
f.w = k
i.w = e
assert e.w.x.w.s.w.x.txt == "i"