Lewis Hamilton ends barren run to claim pole in Hungary