#include using namespace std; using ll = long long; using T = tuple; ll A[200020], B[200020]; int main () { int N, M; cin >> N >> M; for (int i = 1; i <= N; i ++) { cin >> A[i]; } for (int i = 0; i < M; i ++) { cin >> B[i]; } auto cmp = [&] (T a, T b) { auto& [a1, a2, a3] = a; auto& [b1, b2, b3] = b; if (A[a1] * B[b2] != B[a2] * A[b1]) { return A[a1] * B[b2] > B[a2] * A[b1]; } else { return a3 < b3; } }; priority_queue, decltype(cmp)> pque{cmp}; for (int i = 1; i <= N; i ++) { pque.emplace(i, 0, i); } for (int i = 0; i < M; i ++) { auto [a1, a2, a3] = pque.top(); pque.pop(); cout << a1 << endl; pque.emplace(a1, a2 + 1, a3); } }