A Learning Strategy for Contrast-agnostic MRI Segmentation