Nick Kyrgios was up to his usual tricks as he moved into the second round of the Italian Open with a 6-3 3-6 6-3 win over Daniil Medvedev.