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

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

n = A("n")
c = B("c")
i = B("i")
l = B("l")
b = A("b")
f = A("f")
j = B("j")

n.o = b
c.o = j
i.o = c
l.o = i
b.o = n
f.o = n
j.o = l
assert i.o.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.o: B = None
        self.txt = txt

n = A("n")
c = B("c")
i = B("i")
l = B("l")
b = A("b")
f = A("f")
j = B("j")

n.o = b
c.o = j
i.o = c
l.o = i
b.o = n
f.o = n
j.o = l
assert i.o.o.o.o.o.o.o.txt == "l"