A number when divide by 16 leaves 6 remainder, when divided by 17, leaves 7 remainder and when divided by 18 leaves 8 remainder. ID the number is N. Then what will be the remainder when M, where M=N^2 +6N+16 is divided by 12?