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

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

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

e = A("e")
k = B("k")
c = C("c")
n = A("n")
a = B("a")
f = A("f")
j = C("j")

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

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

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

e = A("e")
k = B("k")
c = C("c")
n = A("n")
a = B("a")
f = A("f")
j = C("j")

e.v = n
k.x = a
k.s = f
c.w = a
n.v = f
a.x = k
a.s = e
f.v = e
j.w = k
assert j.w.s.v.v.txt == "n"