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

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

g = A("g")
j = B("j")
c = A("c")
f = B("f")

g.v = f
g.o = f
j.x = g
j.w = g
c.v = j
c.o = f
f.x = c
f.w = c
assert f.x.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
c = A("c")
f = B("f")

g.v = f
g.o = f
j.x = g
j.w = g
c.v = j
c.o = f
f.x = c
f.w = c
assert f.x.o.w.txt == "c"