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

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

k = A("k")
l = B("l")
j = B("j")

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

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

k = A("k")
l = B("l")
j = B("j")

k.v = l
k.s = j
l.s = k
l.v = k
j.s = k
j.v = k
assert j.v.s.s.txt == "k"