Polynomial time solution for bipartite matching
This actually has nothing to do with the stable marriage problem; it's an instance of bipartite matching.  (It's not related to stable marriage, becuase you don't have an ordering on the preferences of which box each item is matched to; you just have a list of what's allowed or disallowed.)

There are efficient algorithms: use the Hungarian algorithm, or any other algorithm for finding a maximum matching in a bipartite graph.  See https://en.wikipedia.org/wiki/Bipartite_matching#In_unweighted_bipartite_graphs, https://en.wikipedia.org/wiki/Hungarian_algorithm, and https://en.wikipedia.org/wiki/Assignment_problem.