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

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

c = A("c")
j = B("j")
k = B("k")
l = A("l")
i = B("i")
g = A("g")
d = A("d")
b = B("b")

c.x = b
j.s = l
k.s = d
l.x = j
i.s = c
g.x = k
d.x = j
b.s = l
assert l.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

c = A("c")
j = B("j")
k = B("k")
l = A("l")
i = B("i")
g = A("g")
d = A("d")
b = B("b")

c.x = b
j.s = l
k.s = d
l.x = j
i.s = c
g.x = k
d.x = j
b.s = l
assert l.x.s.x.txt == "j"