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

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

i = A("i")
k = B("k")
d = A("d")
b = A("b")
j = B("j")

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

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

i = A("i")
k = B("k")
d = A("d")
b = A("b")
j = B("j")

i.r = b
i.o = k
k.v = d
k.o = j
d.r = i
d.o = k
b.r = d
b.o = k
j.v = i
j.o = k
assert i.o.o.v.txt == "i"