rule 1

example 1

rule 2

example 2

rule 3

example 3