Afghanistan’s Karzai slams U.S., Pakistan in farewell speech