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

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

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

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

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

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

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