Checks if input is a magic square