No one knows exactly where thought comes from, but it can be said that thought comes from the same place as whatever it is that beats our heart... it comes from being alive.
In the long history of humankind (and animal kind, too) those who learned to collaborate and improvise most effectively have prevailed.

