Nick Kyrgios beats top-ranked Daniil Medvedev in Montreal