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

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

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

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

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

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

n.s = j
j.x = k
j.s = n
k.s = l
l.x = n
l.s = k
assert n.s.x.s.txt == "l"