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

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

i = A("i")
a = B("a")
l = A("l")
k = B("k")
g = A("g")
n = A("n")
b = B("b")

i.s = a
i.w = a
a.t = k
l.s = b
l.w = k
k.t = b
g.s = a
g.w = a
n.s = k
n.w = a
b.t = a
assert k.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

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

i = A("i")
a = B("a")
l = A("l")
k = B("k")
g = A("g")
n = A("n")
b = B("b")

i.s = a
i.w = a
a.t = k
l.s = b
l.w = k
k.t = b
g.s = a
g.w = a
n.s = k
n.w = a
b.t = a
assert k.t.t.t.t.txt == "b"