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

k = A("k")
c = B("c")
e = B("e")
l = A("l")

k.x = e
c.s = l
e.s = k
l.x = e
assert l.x.s.x.s.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

k = A("k")
c = B("c")
e = B("e")
l = A("l")

k.x = e
c.s = l
e.s = k
l.x = e
assert l.x.s.x.s.txt == "k"