Adding Prime Palindrome and Mth to last element