Optimal Exploitation of Clustering and History Information in Multi-Armed Bandit