#include constexpr int DEBUG = 0; using namespace std; using int64 = long long; template vector> Make2D(int d1, int d2, T default_value) { return vector>(d1, vector(d2, default_value)); } template ostream& operator<<(ostream& s, const vector& v) { s << "["; for (int i = 0; i < int(v.size()); i++) { if (i > 0) { s << ", "; } s << v[i]; } s << "]"; return s; } constexpr int64 INF = 2E18; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, l; cin >> n >> l; vector cs(n); for (int i = 0; i < n; i++) { cin >> cs[i]; } auto count_table = Make2D(n, l + 1, 0); auto c_sum_table = Make2D(n, l + 1 + 1, 0); for (int j = 0; j <= cs[n - 1]; j++) { count_table[n - 1][j] = 1; } for (int j = 0; j <= l; j++) { c_sum_table[n - 1][j + 1] = c_sum_table[n - 1][j] + count_table[n - 1][j]; } for (int i = n - 2; i >= 0; i--) { for (int j = 0; j <= l; j++) { int k = min(j, cs[i]); count_table[i][j] = c_sum_table[i + 1][j + 1] - c_sum_table[i + 1][j - k]; } for (int j = 0; j <= l; j++) { c_sum_table[i][j + 1] = c_sum_table[i][j] + count_table[i][j]; } } cerr << count_table << endl; int q_count; cin >> q_count; for (int q_index = 0; q_index < q_count; q_index++) { int64 q; cin >> q; q--; if (q >= count_table[0][l]) { cout << -1 << endl; continue; } int r = l; int64 b = 0; for (int i = 0; i < n - 1; i++) { for (int j = min(r, cs[i]); j >= 0; j--) { if (q < b + count_table[i + 1][r - j]) { cout << j << " "; r -= j; q -= b; b = 0; break;; } else { b += count_table[i + 1][r - j]; } } } cout << r << endl; } }