#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include using namespace atcoder; #include #define int long long #define double long double #define stoi stoll //#define endl "\n" using std::abs; using namespace std; constexpr double PI = 3.14159265358979323846; const int INF = 1LL << 61; const int dx[8] = { 0,1,0,-1,1,1,-1,-1 }; const int dy[8] = { 1,0,-1,0,1,-1,1,-1 }; #define rep(i,n) for(int i=0;i=0;i--) #define Rrep(i,n) for(int i=n;i>0;i--) #define frep(i,n) for(auto &x:n) #define LAST(x) x[x.size()-1] #define ALL(x) (x).begin(),(x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x) #define RUD(a,b) (((a)+(b)-1)/(b)) #define sum1_n(n) ((n)*(n+1)/2) #define SUM1n2(n) (n*(2*n+1)*(n+1))/6 #define SUMkn(k,n) (SUM1n(n)-SUM1n(k-1)) #define SZ(x) ((int)(x).size()) #define PB push_back #define Fi first #define Se second #define lower(vec, i) *lower_bound(ALL(vec), i) #define upper(vec, i) *upper_bound(ALL(vec), i) #define lower_count(vec, i) (int)(lower_bound(ALL(vec), i) - (vec).begin()) #define acc(vec) accumulate(ALL(vec),0LL) template constexpr auto min(T... a) { return min(initializer_list>{a...}); } template constexpr auto max(T... a) { return max(initializer_list>{a...}); } template void in(T&... a) { (cin >> ... >> a); } void out() { cout << "\n"; } template void out(const T& t, const U &...u) { cout << t; if (sizeof...(u)) cout << sep; out(u...); } template bool nxp(vector& v) { return next_permutation(begin(v), end(v)); } #define inl(...) long long __VA_ARGS__; in(__VA_ARGS__) #define ins(...) string __VA_ARGS__; in(__VA_ARGS__) template using v = vector; template using vv = vector>; template using vvv = vector>; using pint = pair; using tint = tuple; using qint = tuple; double LOG(int a, int b) { return log(b) / log(a); } int DISTANCE(pint a, pint b) { return (abs(a.first - b.first) * abs(a.first - b.first) + abs(a.second - b.second) * abs(a.second - b.second)); } inline bool BETWEEN(int x, int min, int max) { if (min <= x && x <= max) return true; else return false; } inline bool between(int x, int min, int max) { if (min < x && x < max) return true; else return false; } inline bool BETWEEN2(int i, int j, int H, int W) { if (BETWEEN(i, 0, H - 1) && BETWEEN(j, 0, W - 1)) return true; else return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } inline bool bit(int x, int i) { return x >> i & 1; } void yn(bool x) { if (x) { cout << "Yes" << endl; } else { cout << "No" << endl; } } void YN(bool x) { if (x) { cout << "YES" << endl; } else { cout << "NO" << endl; } } int ipow(int x, int n) { int ans = 1; while (n > 0) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } template vector compress(vector& X) { vector vals = X; sort(ALL(vals)); vals.erase(unique(ALL(vals)), vals.end()); rep(i, SZ(X)) X[i] = lower_bound(ALL(vals), X[i]) - vals.begin(); return vals; } v prime_factorize(int N) { v res; for (int i = 2; i * i <= N; i++) { if (N % i != 0) continue; int ex = 0; while (N % i == 0) { ++ex; N /= i; } res.push_back({ i, ex }); } if (N != 1) res.push_back({ N, 1 }); return res; } struct Eratosthenes { v isprime; v minfactor; Eratosthenes(int N) : isprime(N + 1, true), minfactor(N + 1, -1) { isprime[0] = false; isprime[1] = false; minfactor[1] = 1; for (int p = 2; p <= N; ++p) { if (!isprime[p]) continue; minfactor[p] = p; for (int q = p * 2; q <= N; q += p) { isprime[q] = false; if (minfactor[q] == -1) minfactor[q] = p; } } } v factorize(int n) { v res; while (n > 1) { int p = minfactor[n]; int exp = 0; while (minfactor[n] == p) { n /= p; ++exp; } res.emplace_back(p, exp); } return res; } }; int number_of_divisors(v p) { int ans = 1; for (pint x : p) { ans *= x.second + 1; } return ans; } int sum_of_divisors(v p) { int ans = 1; for (pint x : p) { } return ans; } string base_to_k(int n, int k) { //n(10)→n(k) string ans = ""; while (n) { ans += to_string(n % k); n /= k; } reverse(ALL(ans)); return ans; } template< class T > struct CumulativeSum2D { vector< vector< T > > data; CumulativeSum2D(int W, int H) : data(W + 1, vector(H + 1, 0)) {} void add(int x, int y, T z) { ++x, ++y; if (x >= data.size() || y >= data[0].size()) return; data[x][y] += z; } void build() { for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data[i].size(); j++) { data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; } } } T query(int sx, int sy, int gx, int gy) { return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]); } }; /* rep(S, 1 << N) { rep(i, N) { rep(j, N) { if (S != 0 && !(bit(S,i))) continue; if (!bit(S,j)) { if (v != u) chmin(dp[S | (1 << v)][v], dp[S][u] + G[u][v]); } } } } */ //constexpr int MOD = 1000000007; constexpr int MOD = 998244353; //using mint = modint1000000007; using mint = modint998244353; //using mint = static_modint<16637>; void solve() { inl(N, M, P, Q); v x(12,M); rep(i, Q)x[P+i-1] *= 2; int now = 0; while (N>0) { N -= x[now % 12]; now++; cout << N << endl; } cout << now << endl; } signed main() { //ios::sync_with_stdio(false); //cin.tie(nullptr); cout << fixed << setprecision(14); //cout << setfill('0') << right << setw(3); solve(); }