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

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

i = A("i")
h = B("h")
m = A("m")
j = B("j")
b = A("b")
c = A("c")
l = A("l")
d = B("d")

i.o = l
h.v = d
m.o = c
j.v = h
b.o = i
c.o = l
l.o = b
d.v = j
assert c.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

i = A("i")
h = B("h")
m = A("m")
j = B("j")
b = A("b")
c = A("c")
l = A("l")
d = B("d")

i.o = l
h.v = d
m.o = c
j.v = h
b.o = i
c.o = l
l.o = b
d.v = j
assert c.o.o.o.o.o.o.txt == "i"