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

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

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

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

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

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

j.v = h
j.x = l
h.s = l
l.v = h
l.x = j
assert l.x.v.s.txt == "l"