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

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

l = A("l")
k = B("k")
g = B("g")
m = B("m")
i = A("i")

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

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

l = A("l")
k = B("k")
g = B("g")
m = B("m")
i = A("i")

l.u = i
l.t = g
k.s = m
k.w = i
g.s = k
g.w = l
m.s = k
m.w = i
i.u = l
i.t = m
assert i.u.t.s.txt == "k"