rack the brains

See: ponder