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

k = A("k")
e = B("e")
h = B("h")
j = B("j")

k.u = h
e.w = k
h.w = k
j.w = k
assert h.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

k = A("k")
e = B("e")
h = B("h")
j = B("j")

k.u = h
e.w = k
h.w = k
j.w = k
assert h.w.u.w.txt == "k"