if A1:
if A2 == X2:
if B1:
if B2 == Y2:
do_something()
else:
print 'B2 must equal to Y2'
else:
do_something()
else:
print 'A2 must equal to X2'
elif B1:
if B2 == Y2:
do_something()
else:
print 'B2 must equal to Y2'
else:
print 'Choose at least one between A1 and B1'