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

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

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

j.v = n
j.r = n
n.o = i
n.p = j
i.v = n
i.r = n
assert j.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: B = None
        self.txt = txt

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

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

j.v = n
j.r = n
n.o = i
n.p = j
i.v = n
i.r = n
assert j.v.o.v.txt == "n"