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

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

a = A("a")
i = B("i")
c = B("c")
k = B("k")

a.u = i
i.w = a
c.w = a
k.w = a
assert c.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

a = A("a")
i = B("i")
c = B("c")
k = B("k")

a.u = i
i.w = a
c.w = a
k.w = a
assert c.w.u.w.txt == "a"