#include #include using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--) #define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n"); #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; using ll = long long; int main() { int n, m; cin >> n >> m; vector a(n), b(m); rep(i, 0, n) cin >> a[i]; rep(i, 0, m) cin >> b[i]; long double l = 1e-10, r = 1e10; while (abs(max(l, r) / min(l, r)) > 1 + 1e-6) { auto x = (l + r) / 2; ll cnt = 0; rep(i, 0, n) { // b[j] <= a[i] / x auto it = upper_bound(all(b), a[i] / x); cnt += (it - b.begin()); } if (cnt >= m) l = x; else r = x; } using P = pair; using PP = pair; vector ans; rep(i, 0, n) { rep(j, 0, m) { if (a[i] + 10 < l * b[j]) break; ans.push_back(PP(i + 1, P(a[i], b[j]))); } } sort(all(ans), [&](const auto& x, const auto& y) { auto xp = x.second; auto yp = y.second; return xp.first * yp.second > yp.first * xp.second; }); rep(i, 0, m) cout << ans[i].first << "\n"; }