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

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

a = A("a")
h = B("h")
k = B("k")
m = A("m")
c = A("c")
n = A("n")

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

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

a = A("a")
h = B("h")
k = B("k")
m = A("m")
c = A("c")
n = A("n")

a.s = c
h.v = k
k.v = h
m.s = n
c.s = a
n.s = c
assert h.v.v.v.v.v.txt == "k"