Rival ordering by pattern matching