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

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

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

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

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

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

j.w = i
n.v = j
n.x = c
c.v = i
c.x = n
i.w = j
assert i.w.w.w.w.txt == "i"