Nakayama automorphism and applications