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

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

g = A("g")
h = B("h")
c = B("c")
k = A("k")
n = B("n")
b = A("b")
a = B("a")

g.w = k
h.s = k
c.s = k
k.w = g
n.s = k
b.w = k
a.s = k
assert c.s.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

g = A("g")
h = B("h")
c = B("c")
k = A("k")
n = B("n")
b = A("b")
a = B("a")

g.w = k
h.s = k
c.s = k
k.w = g
n.s = k
b.w = k
a.s = k
assert c.s.w.w.w.w.w.w.txt == "k"