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

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

e = A("e")
h = B("h")
k = A("k")
j = B("j")
b = B("b")

e.s = b
h.v = k
k.s = b
j.v = e
b.v = e
assert j.v.s.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

e = A("e")
h = B("h")
k = A("k")
j = B("j")
b = B("b")

e.s = b
h.v = k
k.s = b
j.v = e
b.v = e
assert j.v.s.v.s.v.txt == "e"