I am trying to find a solution to a problem in the best possible way. My code has 2 restrictions:

1) It supports only 50 search parameters.
2) It support (A OR B) AND C but not (A AND B) OR C.

I have a search criteria as:

Name: N1, N2, N3.......N25
Department: D1, D2, D3..........D50
City: C1, C2.....C10

I want to build an algorithm that takes the optimum query to search. I can see only one way is

(N1 OR N2 OR N3 OR .. OR N16) AND (D1 OR D2 OR D3 OR .. OR D16) AND (C1 OR C2 OR C3 OR .. OR C10)

This way I want all combinations to fetch my results. Any ideas would really help. Thanks