Adams inequality with exact growth condition on Rn and Heisenberg group