#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
        if (i > pos)
          break;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size() && i - 5 < pos; ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
        if (i > pos)
          break;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v){
  if (n >= c) {
    auto step = n / c;
    auto p = min(n * v / c - 1, n - 1);
    return p;
  }
  return int(floor(1.0 * n * v / c) - 1);
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      //if (check_val == 0 && i > ex_p)
      //  break;
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size() && i - 5 < pos; ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = 1000000, check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

#pragma GCC optimize("Ofast,no-stack-protector")

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size(); ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
        if (i > pos)
          break;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v) {
  auto b = int(1. * (v - 1) * n / c);
  if (v == c && b + 1 != n)
    return n - 1;
  return b;
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i) {
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val) {
        if (ch == check_val) {
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
    }
    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define sz(v) (int((v).size()))
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
vector<int> nvi(int n, int corr = 0) { vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = ni() + corr; return move(a); }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }
int64_t tr2(int xv1, int yv1, int xv2, int yv2, int x3, int y3) { return 1LL * (xv2 - xv1) * (y3 - yv1) - 1LL * (yv2 - yv1) * (x3 - xv1); }

typedef long double lfloat;
typedef pair<int, int> pint;
const lfloat eps = 1e-12;
const lfloat pi = acos(-1.0);
bool eq(lfloat a, lfloat b) { return abs(a - b) <= eps; }

int8_t bits_cnt[256];
const string input_dir = "inputs\\";
string input_file = input_dir + "input.txt";
string output_file = input_dir + "output.txt";
void init_streams() {
#ifdef _LOCAL_TEST
  freopen(input_file.c_str(), "r", stdin);
  // freopen(output_file.c_str(), "w", stdout);
#endif // _LOCAL_TEST
}

void init_data() {
  for (int i = 1; i <= 255; ++i) for (int j = 0; j < 8; ++j) if ((1 << j) & i) ++bits_cnt[i];
}
int get_bit_count(int v) {
  return bits_cnt[v & 0xFF] + bits_cnt[(v >> 8) & 0xFF] + bits_cnt[(v >> 16) & 0xFF] + bits_cnt[(v >> 24) & 0xFF];
}

bool check(const vector<int>& a) {
  if (count(all(a), -1) == 0)
    return is_sorted(all(a));
  return false;
}

int check_not_worse(int val, vector<int>& a, int pos) {
  auto tmp = a[pos];
  a[pos] = val;
  for (int i = 0, p = -1; i < a.size() && i - 5 < pos; ++i) {
    if (a[i] >= 0) {
      if (p == -1) {
        p = i;
      }
      else {
        if (a[p] > a[i]) {
          a[pos] = tmp;
          return 2;
        }
        p = i;
      }
    }
  }
  a[pos] = tmp;
  return a[pos] == -1 ? 0 : 1;
}

int get_next(vector<int>& nums) {
#ifdef _LOCAL_TEST
  //auto a = nums.front();
  //nums.erase(nums.begin());
  //return a;
#endif // _LOCAL_TEST
  auto v = ni();
  return v;
}

int estimate(int n, int c, int v){
  if (n >= c) {
    auto step = n / c;
    auto p = min(n * v / c - 1, n - 1);
    return p;
  }
  return int(floor(1.0 * n * v / c) - 1);
}

int main()
{
  init_streams();
  init_data();

  auto n = ni(), m = ni(), c = ni();
  vector<int> a(n, -1);
  vector<int> nums{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
  int step = 0;
  while (step++ < m) {
    auto p = get_next(nums);
    auto ex_p = estimate(n, c, p);
    auto idx = -1, dist = (1 << 20), check_val = 2;
    for (int i = 0; i < n; ++i){
      auto ch = check_not_worse(p, a, i);
      if (ch != 2 && ch <= check_val){
        if (ch == check_val){
          if (abs(i - ex_p) < dist) {
            idx = i;
            dist = abs(i - ex_p);
          }
        }
        else {
          idx = i;
          check_val = ch;
          dist = abs(i - ex_p);
        }
      }
      if (check_val == 0 && i > ex_p)
        break;
    }

    a[idx] = p;
    printf("%i\n", idx + 1);
    fflush(stdout);
    if (check(a))
    {
      // cout << "OK with " << step << endl;
      break;
    }
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {

	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
const int MAX_N = 1e3 + 10;
int Nr[MAX_N];
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = (C+2) / 2;
	int l = 1, r = N;
	Nr[N+1] = INF;
	while(M--) {
		int v = getInput();
		if(v >= mid) {
			for(int i=r; i<=N; i++) if(Nr[i+1] >= v) {
				printf("%d\n", i);
				Nr[i] = v;
				if(i == r) r--;
				break;
			}
		}else{
			for(int i=l; i>=1; i--) if(Nr[i-1] <= v) {
				printf("%d\n", i);
				Nr[i] = v;
				if(i == l) l++;
				break;
			}
		}
		fflush(stdout);
		if(r < l) break;
	}
	/*
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		bool uu = (v >= mid);
		if(uu) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			now.insert(ti(v, b+1, b+1));
		}
		if(uu) {
			where = N+1-where;
		}else{
		}
		printf("%d\n", where);
		fflush(stdout);
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		if(sum == N) break;
	}
	*/
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {

	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = (C+2) / 2;
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		bool uu = (v >= mid);
		if(uu) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			now.insert(ti(v, b+1, b+1));
		}
		if(uu) {
			where = N+1-where;
		}else{
		}
		printf("%d\n", where);
		fflush(stdout);
		/*
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		*/
		if(sum == N) break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {

	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = C / 2;
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		if(v >= mid) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			now.insert(ti(v, b+1, b+1));
		}
		if(v >= mid) {
			where = N+1-where;
		}else{
		}
		printf("%d\n", where);
		fflush(stdout);
		/*
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		*/
		if(sum == N) break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {
	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = (C+2) / 2;
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		bool uu = (v >= mid);
		if(uu) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			//sum++;
			int x, a, b; tie(x, a, b) = *who;
			if(x != v) sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			now.insert(ti(v, b+1, b+1));
		}
		if(uu) {
			where = N+1-where;
		}else{
		}
		//printf("%d ", sum);
		printf("%d\n", where);
		fflush(stdout);
		/*
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		*/
		if(sum == N) break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {

	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = (C+2) / 2;
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		bool uu = (v >= mid);
		if(uu) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			//sum++;
			int x, a, b; tie(x, a, b) = *who;
			if(x != v) sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			now.insert(ti(v, b+1, b+1));
		}
		if(uu) {
			where = N+1-where;
		}else{
		}
		//printf("%d ", sum);
		printf("%d\n", where);
		fflush(stdout);
		/*
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		*/
		if(sum == N) break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {

	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = (C+2) / 2;
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		bool uu = (v >= mid);
		if(uu) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			//sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			if(up == now.end()) sum++;
			now.insert(ti(v, b+1, b+1));
		}
		if(uu) {
			where = N+1-where;
		}else{
		}
		//printf("%d ", sum);
		printf("%d\n", where);
		fflush(stdout);
		/*
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		*/
		if(sum == N) break;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, M, C;
bool TEST = false;
int getInput() {
	int v;
	if(TEST) {
	}else scanf("%d", &v);
	return v;
}

typedef tuple<int, int, int> ti;
const int MAX_N = 1e3 + 10;
int Nr[MAX_N];
int main() {
	scanf("%d%d%d", &N, &M, &C);
	int mid = (C+2) / 2;
	int l = 1, r = N;
	Nr[N+1] = INF;
	while(M--) {
		int v = getInput();
		if(v >= mid) {
			for(int i=r; i<=N; i++) if(Nr[i+1] >= v) {
				printf("%d\n", i);
				Nr[i] = v;
				if(i == r) r--;
				break;
			}
		}else{
			for(int i=l; i>=1; i--) if(Nr[i-1] <= v) {
				printf("%d\n", i);
				Nr[i] = v;
				if(i == l) l++;
				break;
			}
		}
		fflush(stdout);
		if(r < l) break;
	}
	/*
	set<ti> a, b;
	a.insert(ti(0, 0, 0));
	b.insert(ti(0, 0, 0));
	int sum = 0;
	while(M--) {
		int v = getInput();
		set<ti> &now = (v < mid ? a : b);
		bool uu = (v >= mid);
		if(uu) v = C+1 - v;

		auto up = now.upper_bound(ti(v, INF, INF));
		auto who = up; who--;
		if(up == now.end()) {
			sum++;
		}else{
			int x, a, b; tie(x, a, b) = *up;
			now.erase(up);
			if(b > a) {
				now.insert(ti(x, a, b-1));
			}
		}
		int x, a, b; tie(x, a, b) = *who;
		int where = b+1;
		if(x == v) {
			now.erase(who);
			now.insert(ti(x, a, b+1));
		}else{
			now.insert(ti(v, b+1, b+1));
		}
		if(uu) {
			where = N+1-where;
		}else{
		}
		printf("%d\n", where);
		fflush(stdout);
		printf("[%d] %d : ", sum, v);
		for(ti p : now) {
			int x, a, b; tie(x, a, b) = p;
			printf("[%d %d %d] ", x, a, b);
		}puts("");
		if(sum == N) break;
	}
	*/
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n,m,c,p;
int a[1005];

int main()
{
    scanf("%d%d%d",&n,&m,&c);
    int l=1,r=n;
    for (int i=0;i<m;i++) {
        scanf("%d",&p);
        if (p>c/2) {
            if (r==n) { printf("%d\n",r); a[r--]=p; }
            else {
                int idx=lower_bound(a+r+1,a+n+1,p)-a;
                if (idx==r+1) { printf("%d\n",r); a[r--]=p; }
                else { printf("%d\n",idx); a[idx]=p; }
            }
        } else {
            if (l==1) { printf("%d\n",l); a[l++]=p; }
            else {
                int idx=lower_bound(a+1,a+l,p)-a;
                if (idx==l) { printf("%d\n",l); a[l++]=p; }
                else { printf("%d\n",idx); a[idx]=p; }
            }

        }
        fflush(stdout);
        if (l>r) break;
    }
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n,m,c,p;
int a[1005];

int main()
{
    scanf("%d%d%d",&n,&m,&c);
    int l=1,r=n;
    for (int i=0;i<m;i++) {
        scanf("%d",&p);
        if (p>c/2) {
            if (r==n) { printf("%d\n",r); a[r--]=p; }
            else {
                int idx=lower_bound(a+r+1,a+n+1,p)-a;//printf("idx:%d r:%d\n",idx,r);
                if (idx==n+1) { printf("%d\n",n); a[n]=p; }
                else if (idx==r+1) { printf("%d\n",r); a[r--]=p; }
                else { printf("%d\n",idx); a[idx]=p; }
            }
        } else {
            if (l==1) { printf("%d\n",l); a[l++]=p; }
            else {
                int idx=upper_bound(a+1,a+l,p)-a;
                if (idx==l) { printf("%d\n",l); a[l++]=p; }
                else { printf("%d\n",idx); a[idx]=p; }
            }

        }
        fflush(stdout);
        if (l>r) break;
    }
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n,m,c,p;
int a[1005];

int main()
{
    scanf("%d%d%d",&n,&m,&c);
    int l=1,r=n;
    for (int i=0;i<m;i++) {
        scanf("%d",&p);
        if (p>c/2) {
            if (r==n) { printf("%d\n",r); a[r--]=p; }
            else {
                int idx=lower_bound(a+r+1,a+n+1,p)-a;//printf("idx:%d r:%d\n",idx,r);
                if (idx==n+1) { printf("%d\n",n); a[n]=p; }
                else if (idx==r+1) { printf("%d\n",r); a[r--]=p; }
                else { printf("%d\n",idx-1); a[idx-1]=p; }
            }
        } else {
            if (l==1) { printf("%d\n",l); a[l++]=p; }
            else {
                int idx=upper_bound(a+1,a+l,p)-a;
                if (idx==l) { printf("%d\n",l); a[l++]=p; }
                else { printf("%d\n",idx); a[idx]=p; }
            }

        }
        fflush(stdout);
        if (l>r) break;
    }
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO ios::sync_with_stdio(false);
#define taskname ""
using namespace std;

int a[N], n;
int bef(int x, int pos, bool &ok) {
    ok = false;int ans = 0;
    FOR(i, pos + 1, n) {
        if (a[i] == 0) ok = true;
        if (a[i] != x && ans == 0) ans = i;
    }
    if (!ans) return n + 1;
    return ans;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
	int m, c, x, cnt = 0;
	scanf("%d %d %d", &n, &m, &c);
	while (m--) {
		scanf("%d", &x);
		int pos = min(n, x);
		int tmp = 1;
		FOR(i, 1, n - 1) if (a[i] != 0 && a[i] <= x) tmp = i + 1;
        if (tmp > pos && a[tmp] == 0) {
            pos = tmp;
        }
        else {
            if(a[pos] == x) {
                bool ok;
                int y = bef(x, pos, ok);
                if (y == n + 1 || !ok) {
                    FORD(i, pos - 1, 1) if (a[i] != x) {
                        pos = i; break;
                    }
                }
                else {
                    if(ok)pos = y;
                }
            }
        }
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		printf("%d\n", pos);
		fflush(stdout);
		if (cnt == n) return 0;
	}
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO ios::sync_with_stdio(false);
#define taskname ""
using namespace std;

int a[N], n;
int bef(int x, int pos) {
    FOR(i, pos + 1, n) {
        if (a[i] != x) return i;
    }
    return n + 1;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
	int m, c, x, cnt = 0;
	scanf("%d %d %d", &n, &m, &c);
	while (m--) {
		scanf("%d", &x);
		int pos = min(n, x);
		if(a[pos] == x) {
            int y = bef(x, pos);
            if (y == n + 1) {
                FORD(i, pos - 1, 1) if (a[i] != x) {
                    pos = i; break;
                }
            }
            else {
                pos = y;
            }
		}
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		printf("%d\n", pos);
		fflush(stdout);
		if (cnt == n) return 0;
	}
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO ios::sync_with_stdio(false);
#define taskname ""
using namespace std;

int a[N], n;

int bef(int x) {
    FOR(i, 1, n) if (a[i] > x || a[i] == 0) return i;
    return 0;
}

int aft(int x) {
    FORD(i, n, 1) if (a[i] < x) return i;
    return 0;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
	int m, c, x, cnt = 0;
	scanf("%d %d %d", &n, &m, &c);
	while (m--) {
		scanf("%d", &x);
		int pos;
        if (x > c / 2) {
            pos = aft(x);
        } else pos = bef(x);
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		printf("%d\n", pos);
		fflush(stdout);
		if (cnt == n) {
            cerr<<"OK";return 0;
        }
	}
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO ios::sync_with_stdio(false);
#define taskname ""
using namespace std;

int a[N], n;
int bef(int x, int pos) {
    FOR(i, pos + 1, n) {
        if (a[i] != x) return i;
    }
    return n + 1;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
    IO;
	int m, c, x, cnt = 0;
	cin>>n>>m>>c;
	while (m--) {
		cin>>x;
		int pos = min(n, x);
		if(a[pos] == x) {
            int y = bef(x, pos);
            if (y == n + 1) {
                FORD(i, pos - 1, 1) if (a[i] != x) {
                    pos = i; break;
                }
            }
            else {
                pos = y;
            }
		}
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		cout<<pos<<flush;
		if (cnt == n) return 0;
	}
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO ios::sync_with_stdio(false);
#define taskname ""
using namespace std;

int a[N], n;
int bef(int x, int pos) {
    FOR(i, pos + 1, n) {
        if (a[i] != x) return i;
    }
    return n + 1;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
    IO;
	int m, c, x, cnt = 0;
	cin>>n>>m>>c;
	while (m--) {
		cin>>x;
		int pos = min(n, x);
		if(a[pos] == x) {
            int y = bef(x, pos);
            if (y == n + 1) {
                FORD(i, pos - 1, 1) if (a[i] != x) {
                    pos = i; break;
                }
            }
            else {
                pos = y;
            }
		}
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		cout<<pos;
		//fflush(stdout);
		if (cnt == n) return 0;
	}
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO cin.tie(NULL);cout.tie(NULL);
#define taskname ""
using namespace std;

int a[N], n;
int bef(int x, int pos) {
    FOR(i, pos + 1, n) {
        if (a[i] != x) return i;
    }
    return n + 1;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
    IO;
	int m, c, x, cnt = 0;
	cin>>n>>m>>c;
	while (m--) {
		cin>>x;
		int pos = min(n, x);
		if(a[pos] == x) {
            int y = bef(x, pos);
            if (y == n + 1) {
                FORD(i, pos - 1, 1) if (a[i] != x) {
                    pos = i; break;
                }
            }
            else {
                pos = y;
            }
		}
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		cout<<pos;
		if (cnt == n) return 0;
	}
}


#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO ios::sync_with_stdio(false);
#define taskname ""
using namespace std;

int a[N], n;
int bef(int x, int pos) {
    FOR(i, pos + 1, n) {
        if (a[i] != x) return i;
    }
    return n + 1;
}

int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
	int m, c, x, cnt = 0;
	scanf("%d %d %d", &n, &m, &c);
	while (m--) {
		scanf("%d", &x);
		int pos = min(n, x);
		int tmp = 1;
		FOR(i, 1, n - 1) if (a[i] != 0 && a[i] <= x) tmp = i + 1;
        if (tmp > pos) {
            pos = tmp;
        }
        else {
            if(a[pos] == x) {
                int y = bef(x, pos);
                if (y == n + 1) {
                    FORD(i, pos - 1, 1) if (a[i] != x) {
                        pos = i; break;
                    }
                }
                else {
                    pos = y;
                }
            }
        }
		if(a[pos] == 0) cnt++;
		a[pos] = x;
		printf("%d\n", pos);
		fflush(stdout);
		if (cnt == n) return 0;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 400005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n, m;
ll c[N];
vector<ll> adj[N];
ll in[N];
ll out[N];
ll cnt = 0;
void dfs(ll curr, ll prev1 = -1) {
  in[curr] = ++cnt;
  for (ll x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr);
    }
  }
  out[curr] = cnt;
}
//
// Created by cs160 on 09-04-2019.
//
// ashishgup git

struct data {
  // Use required attributes
  int mn;

  // Default Values
  data() : mn(0){};
};

struct SegTree {
  int N;
  vector<data> st;
  vector<bool> cLazy;
  vector<int> lazy;

  void init(int n) {
    N = n;
    st.resize(4 * N + 5);
    cLazy.assign(4 * N + 5, false);
    lazy.assign(4 * N + 5, 0);
  }

  // Write reqd merge functions
  void merge(data &cur, data &l, data &r) { cur.mn = l.mn | r.mn; }

  // Handle lazy propagation appriopriately
  void propagate(int node, int L, int R) {
    if (L != R) {
      cLazy[node * 2] = 1;
      cLazy[node * 2 + 1] = 1;
      lazy[node * 2] = lazy[node];
      lazy[node * 2 + 1] = lazy[node];
    }
    st[node].mn = lazy[node];
    cLazy[node] = 0;
    lazy[node] = 0;
  }

  void build(int node, int L, int R) {
    if (L == R) {
      st[node].mn = 1e9;
      return;
    }
    int M = (L + R) / 2;
    build(node * 2, L, M);
    build(node * 2 + 1, M + 1, R);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  data Query(int node, int L, int R, int i, int j) {
    if (cLazy[node])
      propagate(node, L, R);
    if (j < L || i > R)
      return data();
    if (i <= L && R <= j)
      return st[node];
    int M = (L + R) / 2;
    data left = Query(node * 2, L, M, i, j);
    data right = Query(node * 2 + 1, M + 1, R, i, j);
    data cur;
    merge(cur, left, right);
    return cur;
  }

  data pQuery(int node, int L, int R, int pos) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R)
      return st[node];
    int M = (L + R) / 2;
    if (pos <= M)
      return pQuery(node * 2, L, M, pos);
    else
      return pQuery(node * 2 + 1, M + 1, R, pos);
  }

  void Update(int node, int L, int R, int i, int j, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (j < L || i > R)
      return;
    if (i <= L && R <= j) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    Update(node * 2, L, M, i, j, val);
    Update(node * 2 + 1, M + 1, R, i, j, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  void pUpdate(int node, int L, int R, int pos, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    if (pos <= M)
      pUpdate(node * 2, L, M, pos, val);
    else
      pUpdate(node * 2 + 1, M + 1, R, pos, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  data query(int pos) { return pQuery(1, 1, N, pos); }

  data query(int l, int r) { return Query(1, 1, N, l, r); }

  void update(int pos, int val) { pUpdate(1, 1, N, pos, val); }

  void update(int l, int r, int val) { Update(1, 1, N, l, r, val); }
};

// Problem 1 (Max Query - Point Update with Coordinate Compression):
// http://codeforces.com/gym/100733/problem/F Solution 1:
// http://codeforces.com/gym/100733/submission/41643795

// Problem 2 (Min Query - Offline processing):
// https://codeforces.com/problemset/problem/522/D Solution 2:
// https://codeforces.com/contest/522/submission/45493164

int32_t main() {
  //  ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  ll n, m, c;
  cin >> n >> m >> c;

  ll arr[n + 5];

  if (c == 2) {
    ll l = 0, r = n - 1;
    while (l <= r) {
      ll x;
      cin >> x;
      if (x == 1) {
        cout << l + 1 << endl;
        l++;
      } else {
        cout << r + 1 << endl;
        r--;
      }
    }
    return 0;
  }
  memset(arr, -1, sizeof(arr));

  while (m--) {

    ll val = *min_element(arr, arr + n);
    if (val != -1)
      break;
    ll x;
    cin >> x;

    ll st = ((x - 1) * n) / c;

    ll indx = st;
    bool valid = false;
    for (; indx < n; indx++) {
      if (arr[indx] == -1) {
        valid = true;
        break;
      }
      if (arr[indx] > x)
        break;
    }
    if (valid) {
      cout << indx + 1 << endl;
      arr[indx] = x;
      continue;
    }

    indx = st;
    valid = false;
    for (; indx >= 0; indx--) {
      if (arr[indx] == -1) {
        valid = true;
        break;
      }
      if (arr[indx] < x)
        break;
    }

    if (valid) {
      cout << indx + 1 << endl;
      arr[indx] = x;
      continue;
    }

    indx = 0;
    for (indx = 0; indx < n; indx++) {
      if (arr[indx] == -1)
        continue;
      if (arr[indx] > x)
        break;
    }
    indx = min(indx, n - 1);
    arr[indx] = x;
    cout << indx + 1 << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 400005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n, m;
ll c[N];
vector<ll> adj[N];
ll in[N];
ll out[N];
ll cnt = 0;
void dfs(ll curr, ll prev1 = -1) {
  in[curr] = ++cnt;
  for (ll x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr);
    }
  }
  out[curr] = cnt;
}
//
// Created by cs160 on 09-04-2019.
//
// ashishgup git

struct data {
  // Use required attributes
  int mn;

  // Default Values
  data() : mn(0){};
};

struct SegTree {
  int N;
  vector<data> st;
  vector<bool> cLazy;
  vector<int> lazy;

  void init(int n) {
    N = n;
    st.resize(4 * N + 5);
    cLazy.assign(4 * N + 5, false);
    lazy.assign(4 * N + 5, 0);
  }

  // Write reqd merge functions
  void merge(data &cur, data &l, data &r) { cur.mn = l.mn | r.mn; }

  // Handle lazy propagation appriopriately
  void propagate(int node, int L, int R) {
    if (L != R) {
      cLazy[node * 2] = 1;
      cLazy[node * 2 + 1] = 1;
      lazy[node * 2] = lazy[node];
      lazy[node * 2 + 1] = lazy[node];
    }
    st[node].mn = lazy[node];
    cLazy[node] = 0;
    lazy[node] = 0;
  }

  void build(int node, int L, int R) {
    if (L == R) {
      st[node].mn = 1e9;
      return;
    }
    int M = (L + R) / 2;
    build(node * 2, L, M);
    build(node * 2 + 1, M + 1, R);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  data Query(int node, int L, int R, int i, int j) {
    if (cLazy[node])
      propagate(node, L, R);
    if (j < L || i > R)
      return data();
    if (i <= L && R <= j)
      return st[node];
    int M = (L + R) / 2;
    data left = Query(node * 2, L, M, i, j);
    data right = Query(node * 2 + 1, M + 1, R, i, j);
    data cur;
    merge(cur, left, right);
    return cur;
  }

  data pQuery(int node, int L, int R, int pos) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R)
      return st[node];
    int M = (L + R) / 2;
    if (pos <= M)
      return pQuery(node * 2, L, M, pos);
    else
      return pQuery(node * 2 + 1, M + 1, R, pos);
  }

  void Update(int node, int L, int R, int i, int j, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (j < L || i > R)
      return;
    if (i <= L && R <= j) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    Update(node * 2, L, M, i, j, val);
    Update(node * 2 + 1, M + 1, R, i, j, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  void pUpdate(int node, int L, int R, int pos, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    if (pos <= M)
      pUpdate(node * 2, L, M, pos, val);
    else
      pUpdate(node * 2 + 1, M + 1, R, pos, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  data query(int pos) { return pQuery(1, 1, N, pos); }

  data query(int l, int r) { return Query(1, 1, N, l, r); }

  void update(int pos, int val) { pUpdate(1, 1, N, pos, val); }

  void update(int l, int r, int val) { Update(1, 1, N, l, r, val); }
};

// Problem 1 (Max Query - Point Update with Coordinate Compression):
// http://codeforces.com/gym/100733/problem/F Solution 1:
// http://codeforces.com/gym/100733/submission/41643795

// Problem 2 (Min Query - Offline processing):
// https://codeforces.com/problemset/problem/522/D Solution 2:
// https://codeforces.com/contest/522/submission/45493164

int32_t main() {
  //  ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  ll n, m, c;
  cin >> n >> m >> c;

  ll arr[n + 5];

  if (c == 2) {
    ll l = 0, r = n - 1;
    while (l < r) {
      ll x;
      cin >> x;
      if (x == 1) {
        cout << l + 1 << endl;
        l++;
        l = min(l, n - 1);
      } else {
        cout << r + 1 << endl;
        r--;
        r = max(r, 0ll);
      }
    }
    return 0;
  }
  memset(arr, -1, sizeof(arr));

  while (m--) {

    ll val = *min_element(arr, arr + n);
    if (val != -1)
      break;
    ll x;
    cin >> x;

    ll st = ((x - 1) * n) / c;

    ll indx = st;
    bool valid = false;
    for (; indx < n; indx++) {
      if (arr[indx] == -1) {
        valid = true;
        break;
      }
      if (arr[indx] > x)
        break;
    }
    if (valid) {
      cout << indx + 1 << endl;
      arr[indx] = x;
      continue;
    }

    indx = st;
    valid = false;
    for (; indx >= 0; indx--) {
      if (arr[indx] == -1) {
        valid = true;
        break;
      }
      if (arr[indx] < x)
        break;
    }

    if (valid) {
      cout << indx + 1 << endl;
      arr[indx] = x;
      continue;
    }

    indx = 0;
    for (indx = 0; indx < n; indx++) {
      if (arr[indx] == -1)
        continue;
      if (arr[indx] > x)
        break;
    }
    indx = min(indx, n - 1);
    arr[indx] = x;
    cout << indx + 1 << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 400005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n, m;
ll c[N];
vector<ll> adj[N];
ll in[N];
ll out[N];
ll cnt = 0;
void dfs(ll curr, ll prev1 = -1) {
  in[curr] = ++cnt;
  for (ll x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr);
    }
  }
  out[curr] = cnt;
}
//
// Created by cs160 on 09-04-2019.
//
// ashishgup git

struct data {
  // Use required attributes
  int mn;

  // Default Values
  data() : mn(0){};
};

struct SegTree {
  int N;
  vector<data> st;
  vector<bool> cLazy;
  vector<int> lazy;

  void init(int n) {
    N = n;
    st.resize(4 * N + 5);
    cLazy.assign(4 * N + 5, false);
    lazy.assign(4 * N + 5, 0);
  }

  // Write reqd merge functions
  void merge(data &cur, data &l, data &r) { cur.mn = l.mn | r.mn; }

  // Handle lazy propagation appriopriately
  void propagate(int node, int L, int R) {
    if (L != R) {
      cLazy[node * 2] = 1;
      cLazy[node * 2 + 1] = 1;
      lazy[node * 2] = lazy[node];
      lazy[node * 2 + 1] = lazy[node];
    }
    st[node].mn = lazy[node];
    cLazy[node] = 0;
    lazy[node] = 0;
  }

  void build(int node, int L, int R) {
    if (L == R) {
      st[node].mn = 1e9;
      return;
    }
    int M = (L + R) / 2;
    build(node * 2, L, M);
    build(node * 2 + 1, M + 1, R);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  data Query(int node, int L, int R, int i, int j) {
    if (cLazy[node])
      propagate(node, L, R);
    if (j < L || i > R)
      return data();
    if (i <= L && R <= j)
      return st[node];
    int M = (L + R) / 2;
    data left = Query(node * 2, L, M, i, j);
    data right = Query(node * 2 + 1, M + 1, R, i, j);
    data cur;
    merge(cur, left, right);
    return cur;
  }

  data pQuery(int node, int L, int R, int pos) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R)
      return st[node];
    int M = (L + R) / 2;
    if (pos <= M)
      return pQuery(node * 2, L, M, pos);
    else
      return pQuery(node * 2 + 1, M + 1, R, pos);
  }

  void Update(int node, int L, int R, int i, int j, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (j < L || i > R)
      return;
    if (i <= L && R <= j) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    Update(node * 2, L, M, i, j, val);
    Update(node * 2 + 1, M + 1, R, i, j, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  void pUpdate(int node, int L, int R, int pos, int val) {
    if (cLazy[node])
      propagate(node, L, R);
    if (L == R) {
      cLazy[node] = 1;
      lazy[node] = val;
      propagate(node, L, R);
      return;
    }
    int M = (L + R) / 2;
    if (pos <= M)
      pUpdate(node * 2, L, M, pos, val);
    else
      pUpdate(node * 2 + 1, M + 1, R, pos, val);
    merge(st[node], st[node * 2], st[node * 2 + 1]);
  }

  data query(int pos) { return pQuery(1, 1, N, pos); }

  data query(int l, int r) { return Query(1, 1, N, l, r); }

  void update(int pos, int val) { pUpdate(1, 1, N, pos, val); }

  void update(int l, int r, int val) { Update(1, 1, N, l, r, val); }
};

// Problem 1 (Max Query - Point Update with Coordinate Compression):
// http://codeforces.com/gym/100733/problem/F Solution 1:
// http://codeforces.com/gym/100733/submission/41643795

// Problem 2 (Min Query - Offline processing):
// https://codeforces.com/problemset/problem/522/D Solution 2:
// https://codeforces.com/contest/522/submission/45493164

int32_t main() {
  //  ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  ll n, m, c;
  cin >> n >> m >> c;

  ll arr[n + 5];

  if (c == 2) {
    ll l = 0, r = n - 1;
    while (l <= r) {
      ll x;
      cin >> x;
      if (x == 1) {
        cout << l + 1 << endl;
        l++;
        l = min(l, n - 1);
      } else {
        cout << r + 1 << endl;
        r--;
        r = max(r, 0ll);
      }
    }
    return 0;
  }
  memset(arr, -1, sizeof(arr));

  while (m--) {

    ll val = *min_element(arr, arr + n);
    if (val != -1)
      break;
    ll x;
    cin >> x;

    ll st = ((x - 1) * n) / c;

    ll indx = st;
    bool valid = false;
    for (; indx < n; indx++) {
      if (arr[indx] == -1) {
        valid = true;
        break;
      }
      if (arr[indx] > x)
        break;
    }
    if (valid) {
      cout << indx + 1 << endl;
      arr[indx] = x;
      continue;
    }

    indx = st;
    valid = false;
    for (; indx >= 0; indx--) {
      if (arr[indx] == -1) {
        valid = true;
        break;
      }
      if (arr[indx] < x)
        break;
    }

    if (valid) {
      cout << indx + 1 << endl;
      arr[indx] = x;
      continue;
    }

    indx = 0;
    for (indx = 0; indx < n; indx++) {
      if (arr[indx] == -1)
        continue;
      if (arr[indx] > x)
        break;
    }
    indx = min(indx, n - 1);
    arr[indx] = x;
    cout << indx + 1 << endl;
  }

  return 0;
}


#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else
#define dbg(...)   /****nothing****/
#endif
const bool DBF=0;
const int mn=1002;
int a[mn];
int gn,gc,gm;
void out(int p, int val) {
  assert(1<=p&&p<=gn);
  a[p]=val;
  printf("%d\n",p); fflush(stdout);
  if (DBF) {
    printf("%d\n",p); fflush(stdout); for (int x=1;x<=gn;x++) printf("%d ",a[x]==-1?0:a[x]); printf(" end arr\n");
  }
}

int get() {
  int val;
  scanf("%d",&val);
  //val=(rand()%gc)+1; if (DBF) printf("get:%d\n",val);
  return val;
}

bool isdone(int n) {
  for (int x=1;x<=n;x++) {
    if (a[x]==-1) return false;
  }
  for (int x=2;x<=n;x++) {
    if (a[x-1]>a[x]) return false;
  }
  return true;
}

pair<bool,int> decide(int n, int val) {
  int l,r;
  for (int p=1;p<=n;p++) {
    if (a[p]==-1) {l=p; break;}
    if (a[p]>val) return MP(0,p);
  }
  for (int p=n;p>=1;p--) {
    if (a[p]==-1) {r=p; break;}
    if (a[p]<val) return MP(1,p);
  }
  int sum=1+gc;
  int val2=2*val;
  if (val2<sum) return MP(0,l);
  else return MP(1,r);
}
ll gseed;
void play(int n,int m,int c) {
  gn=n;gc=c;gm=m;
  memset(a,-1,sizeof a);
  a[0]=1; a[n+1]=c;
  for (int r=0;r<m;r++) {
    int val=get();
    pair<bool,int> bp=decide(n,val);
    if (bp.fst) a[0]=val-1;
    else a[n+1]=val+1;
    out(bp.snd,val);
    if (isdone(n)) return;
  }
  printf("Failure seed:%lld\n",gseed); exit(-1);
}

void go() {
  for (int k=0;k<500000;k++) {
    ll seed=clock();
    //if (DBF) seed=2329;
    gseed=seed;
    srand(seed);
    int n=rand()%10+1;
    int c=rand()%10+1;
    int m=n*((c+1)/2);
    if (DBF) printf("seed:%lld n:%d m:%d c:%d\n",seed,n,m,c);
    play(n,m,c);
    //if (0==(k&0xff)) {printf("%d\n",k); fflush(stdout);}
  }
}

int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  //go(); return 0;
  int n,m,c; scanf("%d%d%d",&n,&m,&c);
  play(n,m,c);
}


#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else
#define dbg(...)   /****nothing****/
#endif
const int mn=1002;
int a[mn];
int gn,gc,gm;
void out(int p, int val) {
  assert(1<=p&&p<=gn);
  a[p]=val;
  printf("%d\n",p); fflush(stdout);
}

int get() {
  int val;
  scanf("%d",&val);
  //val=(rand()%gc)+1; printf("get:%d\n",val);
  return val;
}

bool isdone(int n) {
  for (int x=1;x<=n;x++) {
    if (a[x]==-1) return false;
  }
  for (int x=2;x<=n;x++) {
    if (a[x-1]>a[x]) return false;
  }
  return true;
}

void decide(int n, int val) {
  pii pl=MP(INF,INF),pr=MP(INF,INF);
  for (int p=1;p<=n;p++) {
    if (a[p-1]<=val&&(a[p]==-1||a[p]>val)) {
      pl=MP(val-a[p-1],p);
      break;
    }
  }
  for (int p=n;p>=1;p--) {
    if (a[p+1]>=val&&a[p]<val) {
      pr=MP(a[p+1]-val,p);
      break;
    }
  }
  pii best=min(pl,pr);
  out(best.snd,val);
}

void play(int n,int m,int c) {
  gn=n;gc=c;gm=m;
  memset(a,-1,sizeof a);
  a[0]=1; a[n+1]=c;
  for (int r=0;r<m;r++) {
    int val=get();
    decide(n,val);
    if (isdone(n)) return;
  }
  assert(0);
}

void go() {
  for (int k=0;k<1000;k++) {
    ll seed=clock();
    srand(seed);
    int n=rand()%50+1;
    int c=rand()%50+1;
    int m=n*((c+1)/2);
    //printf("seed:%lld n:%d m:%d c:%d\n",seed,n,m,c);
    play(n,m,c);
    //if (0==(k&0xff)) {printf("%d\n",k); fflush(stdout);}
  }
}

int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  //go(); return 0;
  int n,m,c; scanf("%d%d%d",&n,&m,&c);
  play(n,m,c);
}


#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else
#define dbg(...)   /****nothing****/
#endif
const bool DBF=0;
const int mn=1002;
int a[mn];
int gn,gc,gm;
void out(int p, int val) {
  assert(1<=p&&p<=gn);
  a[p]=val;
  printf("%d\n",p); fflush(stdout);
  if (DBF) {
    printf("%d\n",p); fflush(stdout); for (int x=1;x<=gn;x++) printf("%d ",a[x]==-1?0:a[x]); printf(" end arr\n");
  }
}

int get() {
  int val;
  scanf("%d",&val);
  //val=(rand()%gc)+1; if (DBF) printf("get:%d\n",val);
  return val;
}

bool isdone(int n) {
  for (int x=1;x<=n;x++) {
    if (a[x]==-1) return false;
  }
  for (int x=2;x<=n;x++) {
    if (a[x-1]>a[x]) return false;
  }
  return true;
}

pair<bool,int> decide(int n, int val) {
  int l,r;
  for (int p=1;p<=n;p++) {
    if (a[p]==-1) {l=p; break;}
    if (a[p]>val) return MP(0,p);
  }
  for (int p=n;p>=1;p--) {
    if (a[p]==-1) {r=p; break;}
    if (a[p]<val) return MP(1,p);
  }
  int sum=1+gc;
  int val2=2*val;
  if (val2<sum) return MP(0,l);
  else return MP(1,r);
}
ll gseed;
void play(int n,int m,int c) {
  gn=n;gc=c;gm=m;
  memset(a,-1,sizeof a);
  a[0]=1; a[n+1]=c;
  for (int r=0;r<m;r++) {
    int val=get();
    pair<bool,int> bp=decide(n,val);
    if (bp.fst) a[0]=val-1;
    else a[n+1]=val+1;
    out(bp.snd,val);
    if (isdone(n)) return;
  }
  printf("Failure seed:%lld\n",gseed); exit(-1);
}

void go() {
  for (int k=0;k<500000;k++) {
    ll seed=clock();
    //if (DBF) seed=2329;
    gseed=seed;
    srand(seed);
    int n=rand()%10+1;
    int c=rand()%10+1;
    int m=n*((c+1)/2);
    if (DBF) printf("seed:%lld n:%d m:%d c:%d\n",seed,n,m,c);
    play(n,m,c);
    //if (0==(k&0xff)) {printf("%d\n",k); fflush(stdout);}
  }
}

int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  go(); return 0;
  int n,m,c; scanf("%d%d%d",&n,&m,&c);
  play(n,m,c);
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> arr;
    while (true)
    {
        int p;
        cin >> p;
        int i = 0;
        while (i < arr.size() && arr[i] <= p)
        {
            i++;
        }
        if (i >= arr.size())
        {
            arr.push_back(p);
        }
        else
        {
            arr[i] = p;
        }
        cout << i + 1 << endl;
        if (arr.size() == n)
            return 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> arr;
    while (true)
    {
        int p;
        cin >> p;
        int i = 0;
        while (i < arr.size() && arr[i] < p)
        {
            i++;
        }
        if (i >= arr.size())
        {
            arr.push_back(p);
        }
        else
        {
            arr[i] = p;
        }
        cout << i + 1 << endl;
        if (arr.size() == n)
            return 0;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int arr[n];
    for (int i = 0; i < n; i++)
        arr[i] = -1;
    while (true)
    {
        int p;
        cin >> p;
        if (p <= c / 2)
        {
            int i = 0;
            while (i < n && arr[i] != -1 && arr[i] <= p)
            {
                i++;
            }
            if (i > n)
                return 0;
            arr[i] = p;
            cout << i + 1 << endl;
        }
        else
        {
            int i = n - 1;
            while (i >= 0 && arr[i] != -1 && arr[i] >= p)
            {
                i--;
            }
            if (i < 0)
                return 0;
            arr[i] = p;
            cout << i + 1 << endl;
        }
        bool res = true;
        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1] || arr[i] == -1)
                res = false;
        }
        if (arr[0] == -1)
            res = false;
        if (res)
            return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int a[10000];
 int n, m, c;
int Check(int l, int r, int x)
{
    if(r - l <= 1)
    {
        if(x >= a[l])
        {
            if(x > a[r])
            {
                a[r] = x;
                return r;
            }
            else
            {
                a[l] = x;
                return l;
            }
        }
    }
    else
    {
        int mid = (l + r)/2;
        if(a[mid] == 0)
        {
            a[mid] = x;
            return mid;
        }
        if(a[mid] <= x)
        {
            return Check(mid + 1, r, x);
        }
        else
        {
            return Check(l, mid, x);
        }
    }
}

bool GameOver()
{
    for(int i = 0; i < n; i++)
        if(!a[i])
        return false;
    return true;
}

int main()
{

    cin >> n >> m >> c;
    while(m--)
    {
        int p;
        cin >> p;
        cout << Check(0, n - 1, p) + 1 << '\n';
        fflush(stdout);
        if(GameOver())
            break;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int a[10000];
 int n, m, c;
int Check(int l, int r, int x)
{
    if(r - l <= 1)
    {
        if(x >= a[l])
        {
            if(x > a[r])
            {
                a[r] = x;
                return r;
            }
            else
            {
                a[l] = x;
                return l;
            }
        }
    }
    else
    {
        int mid = (l + r)/2;
        if(a[mid] == 0)
        {
            a[mid] = x;
            return mid;
        }
        if(a[mid] <= x)
        {
            return Check(mid + 1, r, x);
        }
        else
        {
            return Check(l, mid, x);
        }
    }
}

int Put(int x)
{
    if(x == 1)
    {
        for(int i = 0; i < n; i++)
        {
            if(a[i] != 1)
            {
                a[i] = 1;
                return i;
            }
        }
    }
    else if(x == c)
    {
        for(int i = n - 1; i >= 0; i--)
        {
            if(a[i] != x)
            {
                a[i] = x;
                return i;
            }
        }
    }
    return -1;
}

bool GameOver()
{
    for(int i = 0; i < n; i++)
        if(!a[i])
        return false;
    return true;
}

int main()
{

    cin >> n >> m >> c;
    while(m--)
    {
        int p;
        cin >> p;
        if(p != 1 && p != c)
            cout << Check(0, n - 1, p) + 1 << '\n';
        else
            cout << Put(p) + 1<< '\n';
        fflush(stdout);
        if(GameOver())
            break;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int a[10001];

bool Ok(int n)
{
    for(int i = 0; i < n; i++)
    {
        if(!a[i])
            return false;
    }
    return true;
}

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    while(m--)
    {
        int q;
        cin >> q;
        int p = -1;
        if(q > c / 2)
        {
            for(int i = n - 1; i >= 0; i--)
            {
                if(a[i] < q)
                {
                    p = i;
                    break;
                }
            }
            a[p] = q;
            cout << p + 1<< endl;
            if(Ok(n))
                return 0;
        }
        else
        {
            for(int i = 0; i < n; i++)
            {
                if(a[i] > q || a[i] == 0)
                {
                    p = i;
                    break;
                }
            }
            cout << p + 1<< endl;
            a[p] = q;
            if(Ok(n))
                return 0;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int a[10000];
 int n, m, c;
int Check(int l, int r, int x)
{
    if(r - l <= 1)
    {
        if(x >= a[l])
        {
            if(x >= a[r])
            {
                a[r] = x;
                return r;
            }
            else
            {
                a[l] = x;
                return l;
            }
        }
    }
    else
    {
        int mid = (l + r)/2;
        if(a[mid] == 0)
        {
            a[mid] = x;
            return mid;
        }
        if(a[mid] <= x)
        {
            return Check(mid + 1, r, x);
        }
        else
        {
            return Check(l, mid, x);
        }
    }
}

bool GameOver()
{
    for(int i = 0; i < n; i++)
        if(!a[i])
        return false;
    return true;
}

int main()
{

    cin >> n >> m >> c;
    while(m--)
    {
        int p;
        cin >> p;
        cout << Check(0, n - 1, p) + 1 << '\n';
        fflush(stdout);
        if(GameOver())
            break;
    }
    return 0;
}


#include<cstdio>
#include<vector>

int main(){

    long n, m, c; scanf("%ld %ld %ld", &n, &m, &c);
    std::vector<long> a(n, 0);
    long rem(n);long pos(0);
    while(rem){
        long x; scanf("%ld", &x);
        if(2 * x <= c){pos = 0; while(a[pos] && a[pos] <= x){++pos;}}
        else{pos = n - 1; while(a[pos] && a[pos] >= x){--pos;}}
        rem -= (a[pos] == 0);
        a[pos] = x;
        printf("%ld\n", pos + 1);
        fflush(stdout);
    }

    return 0;
}


#include <cstdio>
#include <vector>

int main(){

    long n, m, c; scanf("%ld %ld %ld", &n, &m, &c);
    std::vector<long> v;
    for(long p = 0; p < m; p++){
        long x; scanf("%ld", &x);
        long pos(-1);
        if(v.size() == 0 || x >= v.back()){v.push_back(x); pos = v.size();}
        else if(x <= v[0]){v[0] = x; pos = 1;}
        else{
            std::vector<long>::iterator it = std::upper_bound(v.begin(), v.end(), x);
            *it = x;
            pos = it - v.begin() + 1;
        }

        printf("%ld\n", pos);
        fflush(stdout);
        if(v.size() == n){break;}
    }

    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

int main(){

    long n, m, c; scanf("%ld %ld %ld", &n, &m, &c);
    std::vector<long> vl, vr;
    for(long p = 0; p < m; p++){
        long x; scanf("%ld", &x);
        long pos(-1);
        if(2 * x < c){
            if(vl.size() == 0 || x >= vl.back()){vl.push_back(x); pos = vl.size();}
            else if(x <= vl[0]){vl[0] = x; pos = 1;}
            else{
                std::vector<long>::iterator it = std::upper_bound(vl.begin(), vl.end(), x);
                *it = x;
                pos = it - vl.begin() + 1;
            }
        }
        else{
            x = c + 1 - x;
            if(vr.size() == 0 || x >= vr.back()){vr.push_back(x); pos = vr.size();}
            else if(x <= vr[0]){vr[0] = x; pos = 1;}
            else{
                std::vector<long>::iterator it = std::upper_bound(vr.begin(), vr.end(), x);
                *it = x;
                pos = it - vr.begin() + 1;
            }

            pos = n + 1 - pos;
        }

        printf("%ld\n", pos);
        fflush(stdout);
        if(vl.size() + vr.size() == n){break;}
    }

    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

int main(){

    long n, m, c; scanf("%ld %ld %ld", &n, &m, &c);
    std::vector<long> v;
    for(long p = 0; p < m; p++){
        long x; scanf("%ld", &x);
        long pos(-1);
        if(v.size() == 0 || x >= v.back()){v.push_back(x); pos = v.size();}
        else if(x <= v[0]){v[0] = x; pos = 1;}
        else{
            std::vector<long>::iterator it = std::upper_bound(v.begin(), v.end(), x);
            *it = x;
            pos = it - v.begin() + 1;
        }

        printf("%ld\n", pos);
        fflush(stdout);
        if(v.size() == n){break;}
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;

int n,m,c,d;
int a[N];

int main() {
	scanf("%d%d%d",&n,&m,&c);
	d=(c+1)/2;
	int l=1,r=n;
	while (l<=r) {
		int x; scanf("%d",&x);
		if (x<=d) {
			int flag=0;
			for (int i=1;i<l;i++) {
				if (x<a[i]) {
					printf("%d\n",i);
					flag=1; a[i]=x;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",l); a[l]=x; l++;
			}
		}
		else {
			int flag=0;
			for (int i=n;i>r;i--) {
				if (x>a[i]) {
					printf("%d\n",i);
					flag=1; a[i]=x;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",r); a[r]=x; r++;
			}
		}
		fflush(stdout);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;

int n,m,c,d;
int a[N];

int main() {
	scanf("%d%d%d",&n,&m,&c);
	d=(c+1)/2;
	int l=1,r=n;
	while (l<=r) {
		int x; scanf("%d",&x);
		if (x<=d) {
			int flag=0;
			for (int i=1;i<l;i++) {
				if (x<a[i]) {
					printf("%d\n",i);
					flag=1; a[i]=x;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",l); a[l]=x; l++;
			}
		}
		else {
			int flag=0;
			for (int i=n;i>r;i--) {
				if (x>a[i]) {
					printf("%d\n",i);
					flag=1; a[i]=x;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",r); a[r]=x; r--;
			}
		}
		fflush(stdout);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;

int n,m,c,d;
int a[N];

int main() {
	scanf("%d%d%d",&n,&m,&c);
	d=(c+1)/2;
	int l=1,r=n;
	while (l<=r) {
		int x; scanf("%d",&x);
		if (x<=d) {
			int flag=0;
			for (int i=n;i>r;i--) {
				if (x<a[i]) {
					printf("%d\n",i);
					flag=1;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",r); a[r]=x; r--;
			}
		}
		else {
			int flag=0;
			for (int i=1;i<l;i++) {
				if (x>a[i]) {
					printf("%d\n",i);
					flag=1;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",l); a[l]=x; l++;
			}
		}
		fflush(stdout);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;

int n,m,c,d;
int a[N];

int main() {
	scanf("%d%d%d",&n,&m,&c);
	d=(c+1)/2;
	int l=1,r=n;
	while (l<=r) {
		int x; scanf("%d",&x);
		if (x<=d) {
			int flag=0;
			for (int i=n;i>r;i--) {
				if (x<a[i]) {
					printf("%d\n",i);
					flag=1;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",r); a[r]=x; r--;
			}
		}
		else {
			int flag=0;
			for (int i=1;i<l;i++) {
				if (x>a[i]) {
					printf("%d\n",i);
					flag=1;
					break;
				}
			}
			if (!flag) {
				printf("%d\n",l); a[l]=x; l++;
			}
		}
		if (l<=r) fflush(stdout);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> c >> m;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  c = (c + 1) / 2;
  while (!ok) {
    int u; cin >> u;
    if (u <= c) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          a[i] = u;
          cout << i + 1 << endl;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          a[i] = u;
          cout << i + 1 << endl;
          break;
        }
      }
    }
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    rep(i, n - 1) if (a[i + 1] < a[i]) {
      ok = false;
      break;
    }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  cin >> n >> c >> m;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  c /= 2;
  while (!ok) {
    int u; cin >> u;
    int ans = -1;
    if (u <= c) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          ans = i;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          ans = i;
          break;
        }
      }
    }
    assert(ans != -1);
    a[ans] = u;
    cout << ans + 1 << endl;
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    rep(i, n - 1) if (a[i + 1] < a[i]) {
      ok = false;
      break;
    }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> c >> m;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  while (!ok) {
    int u; cin >> u;
    if (u < c / 2) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          a[i] = u;
          cout << i + 1 << endl;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          a[i] = u;
          cout << i + 1 << endl;
          break;
        }
      }
    }
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    rep(i, n - 1) if (a[i + 1] < a[i]) {
      ok = false;
      break;
    }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> c >> m;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  c /= 2;
  while (!ok) {
    int u; cin >> u;
    if (u <= c) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          a[i] = u;
          cout << i + 1 << endl;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          a[i] = u;
          cout << i + 1 << endl;
          break;
        }
      }
    }
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    rep(i, n - 1) if (a[i + 1] < a[i]) {
      ok = false;
      break;
    }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  cin >> n >> c >> m;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  c /= 2;
  while (!ok) {
    int u; cin >> u;
    int ans = -1;
    if (u <= c) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          ans = i;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          ans = i;
          break;
        }
      }
    }
    assert(ans != -1);
    a[ans] = u;
    cout << ans + 1 << endl;
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    //rep(i, n) clog << a[i] << ' ';
    //clog << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  cin >> n >> m >> c;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  c /= 2;
  while (!ok) {
    int u; cin >> u;
    int ans = -1;
    if (u <= c) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          ans = i;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          ans = i;
          break;
        }
      }
    }
    assert(ans != -1);
    a[ans] = u;
    cout << ans + 1 << endl;
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    //rep(i, n) clog << a[i] << ' ';
    //clog << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define len(x) ((int)x.size())

#define maxn 1010
int n, c, m;
int a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> c >> m;
  memset(a, -1, sizeof(a));
  bool ok = 0;
  c /= 2;
  while (!ok) {
    int u; cin >> u;
    int ans = -1;
    if (u <= c) {
      rep(i, n) {
        if (a[i] == -1 or a[i] > u) {
          ans = i;
          break;
        }
      }
    } else {
      for (int i = n; i--; ) {
        if (a[i] == -1 or a[i] < u) {
          ans = i;
          break;
        }
      }
    }
    assert(ans != -1);
    a[ans] = u;
    cout << ans + 1 << endl;
    ok = true;
    rep(i, n) if (a[i] == -1) {
      ok = false;
      break;
    }
    rep(i, n - 1) if (a[i + 1] < a[i]) {
      ok = false;
      break;
    }
  }

  return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e3+_;

int a[maxn];
int main()
{
	int n,m,c,l=0,r,x,p;
	scanf("%d%d%d",&n,&m,&c);r=n+1;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		if(x<=c/2)
		{
			p=l+1;
			for(int i=1;i<=l;i++)
				if(a[i]>x){p=i;break;}
			printf("%d\n",p); fflush(stdout);
			a[p]=x;
			if(p==l+1){l++;if(l+1==r)break;}
		}
		else
		{
			p=r-1;
			for(int i=r;i<=n;i++)
				if(a[i]<x){p=i;break;}
			printf("%d\n",p); fflush(stdout);
			a[p]=x;
			if(p==r-1){r--;if(l+1==r)break;}
		}
	}

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e5+_;
const int mod=1e9+7;
inline int ad(int x,int y){return x>=mod-y?x-mod+y:x+y;}
inline int re(int x,int y){return x<y?x-y+mod:x-y;}
inline int mu(int x,int y){return (LL)x*y%mod;}
inline int qp(int x,LL y){int r=1;while(y){if(y&1)r=mu(x,x);x=mu(x,x),y>>=1;}return r;}
inline int iv(int x){return qp(x,mod-2);}

int a[1100],p;
void solve(int l,int r,int x)
{
	if(l==r){a[l]=x;p=l;return ;}
	if(r-l==1)
	{
		if(a[l]==0)a[l]=x,p=l;
		else if(a[r]==0)a[r]=x,p=r;
		else if(a[l]>x)a[l]=x,p=l;
		else a[r]=x,p=r;
		return ;
	}
	int mid=(l+r)/2;
	if(a[mid]==0)a[mid]=x;
	else if(a[mid]<=x)solve(mid+1,r,x);
	else solve(l,mid,x);
}

int main()
{
	int n,m,c,x;
	scanf("%d%d%d",&n,&m,&c);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		solve(1,n,x);
		printf("%d\n",p);
		fflush(stdout);
		bool bk=false;
		for(int i=1;i<n;i++)
			if(a[i]==0||a[i]>a[i+1]){bk=true;break;}
		bk|=(a[n]==0);
		if(!bk)break;
	}

	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e3+_;

int a[maxn];
int main()
{
	int n,m,c,l=0,r,x,p;
	scanf("%d%d%d",&n,&m,&c);r=n+1;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		if(x<=c/2)
		{
			p=l+1;
			for(int i=1;i<=l;i++)
				if(a[i]>x){p=i;break;}
			printf("%d\n",p); fflush(stdout);
			a[p]=x;
			if(p==l+1){l++;if(l+1==r)break;}
		}
		else
		{
			p=r-1;
			for(int i=n;i>=r;i--)
				if(a[i]<x){p=i;break;}
			printf("%d\n",p); fflush(stdout);
			a[p]=x;
			if(p==r-1){r--;if(l+1==r)break;}
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<setprecision(15)<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second
#define ld long double
ld pi=3.14159265359;

const int N=1002;
int arr[N];

int32_t main(){
	int n,m,c;
	cin>>n>>m>>c;

	multiset <int> cl;
	multiset <int,greater<int> > cr;
	cl.insert(1);
	cr.insert(c);

	F(i,1,m){
		int x,pos;
		cin>>x;

		int a=*cl.rbegin();
		int b=*cr.rbegin();
		if(a<=x && b>=x){
			if(abs(a-x)<=abs(b-x)) pos=cl.size(),cl.insert(x);
			else pos=n-cr.size()+1,cr.insert(x);
		}
		else if(x<a){
			int tmp=*cl.lower_bound(x+1);
			pos=arr[tmp];
			cl.insert(x);
			cl.erase(cl.find(tmp));
		}
		else{
			int tmp=*cl.lower_bound(x-1);
			pos=arr[tmp];
			cl.insert(x);
			cl.erase(cl.find(tmp));
		}

		arr[x]=pos;
		cout<<pos<<endl;
		if(cl.size()+cr.size()==n+2) exit(0);
	}
}