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

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

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

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

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

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

j.o = c
j.v = c
h.r = f
h.x = j
c.o = j
c.v = j
f.r = h
f.x = j
assert j.o.o.v.v.txt == "j"