Medvedev stuns second seed Thiem in Montreal