ordered edit distance rewritten