Algorithm template for OI