#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, w; cin >> n >> m >> w; vector> merch(n); for (int i=0;i> merch[i].first; for (int i=0;i> merch[i].second; vector> magic(m); for (int i=0;i> magic[i].first; for (int i=0;i> magic[i].second; long long ans {}; for (int i=1;i<(1<<(n+m));++i) { pair ans_tmp {}; vector weights; for (int j=0;j