Nasdaq quarterly profit tops estimates as indexes shine