Generalized Principle of Pattern Multiplication and Its Applications