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

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

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

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

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

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

k.s = l
c.u = m
c.w = m
l.s = k
m.u = c
m.w = c
assert l.s.s.s.s.txt == "l"