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

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

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

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

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

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

n.o = i
n.v = j
i.r = l
i.t = n
l.o = j
l.v = i
j.r = n
j.t = l
assert j.r.o.r.v.txt == "i"