#include <bits/stdc++.h>
using namespace std;
template <class T>
int size(const T& a) {
  return int(a.size());
}
template <class T>
T sqr(const T& a) {
  return a * a;
}
const int max_e = 5000, max_n = 110;
struct Edge {
  int v;
  Edge* next;
  Edge* p;
  int bridge;
  bool rem;
  void Add(int v, Edge*& head, Edge* p) {
    this->v = v;
    this->next = head;
    this->p = p;
    this->rem = false;
    head = this;
    bridge = 0;
  }
} edges[max_e];
Edge* h[max_n];
int ct;
int was[max_n];
int vb = 0;
int dfs(int i, Edge* re) {
  was[i] = ++ct;
  int ret = ct;
  for (Edge* e = h[i]; e; e = e->next) {
    if (e->rem || e == re) continue;
    if (was[e->v]) {
      ret = min(ret, was[e->v]);
    } else {
      int cur = dfs(e->v, e->p);
      if (cur > was[i]) {
        e->bridge = e->p->bridge = vb;
      }
      ret = min(ret, cur);
    }
  }
  return ret;
}
void Add(int v1, int v2) {
  static Edge* e = edges;
  (e + 0)->Add(v2, h[v1], e + 1);
  (e + 1)->Add(v1, h[v2], e + 0);
  e += 2;
}
int p[max_e];
Edge* g[max_n];
int main() {
  int n, m, s;
  scanf("%d %d", &n, &m);
  scanf("%d", &s);
  s--;
  for (int i = 0; i < m; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    if (i) {
      Add(p[i - 1], p[i]);
    } else {
      Add(s, p[i]);
    }
  }
  int gi = -1;
  int last = s;
  for (int i = 0; i < m; i++) {
    memset(was, 0, sizeof(was));
    vb++;
    ct = 0;
    dfs(last, NULL);
    int st = vb + 1;
    {
      for (Edge* e = h[last]; e; e = e->next) {
        if (e->rem == false && e->bridge != vb) {
          st = vb;
          break;
        }
      }
    }
    {
      for (Edge* e = h[last]; e; e = e->next) {
        if (e->rem == false && e->bridge != st) {
          if (e->v > p[i]) gi = i;
          g[e->v] = e;
        }
      }
    }
    Edge* e = g[p[i]];
    e->rem = e->p->rem = true;
    last = p[i];
  }
  if (gi == -1) {
    printf("No solution\n");
    return 0;
  }
  for (int i = 0; i < m + m; i++) {
    edges[i].rem = false;
  }
  printf("%d", s + 1);
  last = s;
  for (int i = 0; i < m; i++) {
    memset(was, 0, sizeof(was));
    vb++;
    ct = 0;
    dfs(last, NULL);
    int st = vb + 1;
    for (Edge* e = h[last]; e; e = e->next) {
      if (e->rem == false && e->bridge != vb) {
        st = vb;
        break;
      }
    }
    memset(g, 0, sizeof(g));
    for (Edge* e = h[last]; e; e = e->next) {
      if (e->rem == false && e->bridge != st) {
        g[e->v] = e;
      }
    }
    int v = -1;
    if (i < gi) {
      v = p[i];
    } else if (i == gi) {
      for (int j = p[i] + 1; j < n; j++) {
        if (g[j]) {
          v = j;
          break;
        }
      }
    } else {
      for (int j = 0; j < n; j++) {
        if (g[j]) {
          v = j;
          break;
        }
      }
    }
    Edge* e = g[v];
    e->rem = e->p->rem = true;
    last = v;
    printf(" %d", v + 1);
  }
  return 0;
}
