Heavy flavors in nucleus-nucleus collisions at RHIC and LHC