#include<iostream>
using namespace std;
int main()
{
    int* arr;
    int* brr;
    int n, q;
    cin >> n >> q;
    arr = new int[n];
    brr = new int[q];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 0; i < q; i++)
        cin >> brr[i];

    for (int i = 0; i < q; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (brr[i] == arr[j])
            {
                cout << j + 1<<" ";
                int store = arr[j];
                for (int k = j; k > 0; k--)
                    arr[k] = arr[k-1];
                arr[0] = store;
                break;
            }
        }
    }
    return 0;
}