// 11493 #include #include int min(int a, int b){ return (a= twoplanks) return fullplanks+2*twoplanks; else return -1; } else return -1; } int main(){ int N,M; cin >> N; cin >> M; while (N>0) { int L, K; cin >> L; cin >> K; int count[10001] = {0}; for (int i=0; i> x; count[x]++; } int method1 = calculate(count,N,M,L); int method2 = calculate(count,M,N,L); if (method1==-1 && method2==-1) cout << "impossivel\n"; else if (method1==-1) cout << method2 << "\n"; else if (method2==-1) cout << method1 << "\n"; else cout << min(method1,method2) << "\n"; cin >> N; cin >> M; } }