Detection of Maternal and Fetal Stress from ECG with Self-supervised Representation Learning