#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
int N;
int S;
int check;
cin >> N >> S;
vector<int> arr(S);
vector<int> result(N);
for (int i = 0; i < N; i++)
{
result[i] = 0;
}
for (int i = 0; i < S; i++)
{
cin >> arr[i];
}
for (int i = 0; i < S; i++)
{
for (int j = 0; j < N; j++)
{
if (arr[i] == result[j])
{
check = j;
break;
}
else
{
check=0;
}
}
if (check > 0)
{
for (int k = check; k >= 1; k--)
{
result[k] = result[k - 1];
}
result[0] = arr[i];
}
else
{
for (int j = N - 1; j >= 1; j--)
{
result[j] = result[j - 1];
}
result[0] = arr[i];
}
}
for (int i = 0; i < N; i++)
{
cout << result[i] << " ";
}
}