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

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

m = A("m")
i = B("i")
k = A("k")
e = A("e")

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

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

m = A("m")
i = B("i")
k = A("k")
e = A("e")

m.u = i
i.s = m
k.u = i
e.u = i
assert k.u.s.u.s.txt == "m"