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

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

j = A("j")
a = B("a")
i = A("i")
e = B("e")
k = B("k")

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

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

j = A("j")
a = B("a")
i = A("i")
e = B("e")
k = B("k")

j.v = i
a.s = i
i.v = j
e.s = i
k.s = j
assert e.s.v.v.txt == "i"