#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4;
int a[maxn], n, m, c, bk;
bool check() {
  for (int i = 1; i < n; i++)
    if (a[i] > a[i + 1] || !a[i]) return false;
  return true;
}
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
void write(int x) {
  printf("%d\n", x);
  fflush(stdout);
}
int main() {
  scanf("%d%d%d", &n, &m, &c);
  while (m--) {
    int x = read();
    if (x == 1) {
      int pos = 1;
      while (a[pos] == 1) pos++;
      a[pos] = 1;
      write(pos);
    } else if (x == c) {
      int pos = n;
      while (a[pos] == c) pos--;
      a[pos] = c;
      write(pos);
    } else {
      int bp = n * x / (c + 1) + 1;
      while (bp < 1) bp++;
      while (bp > n) bp--;
      bool put = false;
      for (int i = 1; i < bp; i++)
        if (a[i] && a[i] > x) {
          for (int j = i; j; j--)
            if (!a[j]) {
              put = true, write(j), a[j] = x;
              break;
            }
          if (!put) write(i), a[i] = x, put = true;
          break;
        }
      if (put) continue;
      for (int i = n; i > bp; i--)
        if (a[i] && a[i] < x) {
          for (int j = i; j <= n; j++)
            if (!a[j]) {
              put = true, write(j), a[j] = x;
              break;
            }
          if (!put) write(i), a[i] = x, put = true;
          break;
        }
      if (put) continue;
      if (!a[bp])
        write(bp), a[bp] = x;
      else {
        if (a[bp] == x) {
          int l = bp, r = bp;
          while (a[l] == a[bp] && l >= 1) l--;
          while (a[r] == a[bp] && r <= n) r++;
          if (l != 0 && r != n + 1) {
            if (r - bp > bp - l)
              write(l), a[l] = x;
            else
              write(r), a[r] = x;
          } else if (l == 0)
            write(r), a[r] = x;
          else if (r == n + 1)
            write(l), a[l] = x;
        } else if (a[bp] > x) {
          while (a[bp] && a[bp] > x && bp > 1) bp--;
          write(bp);
          a[bp] = x;
        } else if (a[bp] < x) {
          while (a[bp] && a[bp] < x && bp < n) bp++;
          write(bp);
          a[bp] = x;
        }
      }
    }
    if (check()) break;
  }
}
