Global and Local Contrastive Learning for Joint Representations from Cardiac MRI and ECG