#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

struct hoge{
  public:
  LL a, b, c, d;
  public:
  LL num;

public:
  hoge(LL a, LL b, LL c, LL d,LL num) : a(a), b(b), c(c), d(d),num(num) {}
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  LL n, q, k, d;
  cin >> n >> q >> k >> d;

  k--;
  d--;

  vector<hoge> v;

  v.push_back(hoge(d, d, d, d, 1));

  FOR(i,1,q+1){
    hoge prev = v[i - 1];
    hoge nowhoge = hoge((prev.a * 2) % n, (prev.b * 2) % n, (prev.c * 2) % n, (prev.d * 2+1) % n, (prev.num * 2));

    if(nowhoge.d<nowhoge.a){
      nowhoge.d += n;
    }

    if (nowhoge.num >= n)
    {
      nowhoge.d += n;
      v.push_back(nowhoge);
      break;
    }
    v.push_back(nowhoge);
  }

  hoge last = v[v.size() - 1];

  LL now = k;

  if(last.num>=n){
    for (LL i = 0; i < q - v.size() + 1;++i)
    {
      if(now%2==0){
        cout << 0 << endl;
      }
      else
      {
        cout << 1 << endl;
      }
      now /= 2;
    }
  }

  REP(i,v.size()-1){
    hoge nowhoge = v[v.size() - i-1];
    hoge nexthoge = v[v.size() - i-2];

    bool flag = false;
    REP(j, 2)
    {
      //cout << nowhoge.a << " " << now << " " << nowhoge.d << endl;
      if (nowhoge.a <= now && now <= nowhoge.d)
      {

        bool a = now % 2 == 0;

        now = ((now - nowhoge.a) / 2 + nexthoge.a) % n;

        if(a ^ (now/(n/2)!=0))
        {
          cout << 0 << endl;
        }else{
          cout << 1 << endl;
        }

        flag = true;
        break;
      }
      now += n;
    }
    if(flag)
      continue;

    cout << -1 << endl;
    break;
  }
}

