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

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

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

b = A("b")
a = B("a")
g = C("g")
k = C("k")
e = A("e")
i = B("i")

b.s = g
a.w = b
a.u = i
g.t = k
g.y = a
k.t = g
k.y = a
e.s = k
i.w = e
i.u = a
assert k.y.w.s.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
g = C("g")
k = C("k")
e = A("e")
i = B("i")

b.s = g
a.w = b
a.u = i
g.t = k
g.y = a
k.t = g
k.y = a
e.s = k
i.w = e
i.u = a
assert k.y.w.s.t.t.txt == "g"