Can you set your source page to only send AccountId parameter if there is an Account Id to send? The conditions have options as to what to do if a URL parameter is not found. One is deactivate condition. So, you could change your condition logic to 1 AND 2, then have the condition for AccountId deactivate if that parameter is not in the URL and the same for the ContactId.