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

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

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

c.v = b
c.q = n
i.o = b
i.w = n
b.v = c
b.q = i
n.o = c
n.w = i
assert i.w.w.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

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

c.v = b
c.q = n
i.o = b
i.w = n
b.v = c
b.q = i
n.o = c
n.w = i
assert i.w.w.w.o.txt == "c"