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

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

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

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

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

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

l.w = c
l.s = k
c.o = l
k.w = c
k.s = l
assert k.w.o.w.txt == "c"