Were M4 and M5 written by a cinematographer whose spouse married M2 and M3 and executive produced by a film producer
SELECT count(*) WHERE {
?x0 a ns:film.producer .
?x1 a ns:film.cinematographer .
?x1 ns:people.person.spouse_s/ns:people.marriage.spouse|ns:fictional_universe.fictional_character.married_to/ns:fictional_universe.marriage_of_fictional_characters.spouses ?x2 .
?x2 ns:people.person.spouse_s/ns:people.marriage.spouse|ns:fictional_universe.fictional_character.married_to/ns:fictional_universe.marriage_of_fictional_characters.spouses M2 .
?x2 ns:people.person.spouse_s/ns:people.marriage.spouse|ns:fictional_universe.fictional_character.married_to/ns:fictional_universe.marriage_of_fictional_characters.spouses M3 .
FILTER ( ?x1 != ?x2 ) .
FILTER ( ?x2 != M2 ) .
FILTER ( ?x2 != M3 ) .
M4 ns:film.film.executive_produced_by ?x0 .
M4 ns:film.film.written_by ?x1 .
M5 ns:film.film.executive_produced_by ?x0 .
M5 ns:film.film.written_by ?x1
}