#include <bits/stdc++.h>
using namespace std;
int puse;
int n, m, c;
int let[1000 + 1];
int a[1000 + 1];
int baga(int nr) {
  if (a[n] != 0 && nr > a[n]) {
    a[n] = nr;
    return n;
  }
  int i;
  for (i = let[nr]; i <= n; i++) {
    if (a[i] > nr) break;
    if (a[i] == 0) {
      a[i] = nr;
      puse++;
      return i;
    }
  }
  if (a[let[nr]] < nr) {
    for (i = let[nr]; i < n; i++) {
      if (a[i + 1] > nr) {
        a[i] = nr;
        return i;
      }
    }
    a[n] = nr;
    return n;
  }
  int cr = max(let[nr] - 1, 1);
  while (cr > 0 && a[cr] != 0 && nr <= a[cr]) {
    cr--;
  }
  if (cr == 0) cr++;
  if (a[cr] == 0) puse++;
  a[cr] = nr;
  return cr;
}
void ansQues() {
  srand(time(0));
  while (m > 0) {
    int a;
    cin >> a;
    cout << baga(a) << "\n";
    fflush(stdout);
    if (puse == n) exit(0);
    m--;
  }
}
int main() {
  cin >> n >> m >> c;
  if (c == 2) {
    let[1] = 1;
    let[2] = n;
  } else if (c > n) {
    int buc = c / n;
    int dr = buc;
    int st = 1;
    for (int i = 1; i <= n; i++, st = dr + 1, dr = dr + buc) {
      if (i == n) dr = c;
      for (int j = st; j <= dr; j++) let[j] = i;
    }
  } else {
    int cate = n / c;
    int st = 1;
    int dr = cate + n % c;
    for (int i = 1; i <= c; i++, st = dr + 1, dr = dr + cate) {
      if (i == c) dr = n;
      let[i] = st;
    }
  }
  let[c] = n;
  ansQues();
  return 0;
}
