#include <iostream>
#include <vector>

using namespace std;

struct Node {
    int data;
    Node* next;
};  

int findIndex(Node* & color, int k) {
    int index = 1, minus = 0;
    Node* tmp = color;
    while (tmp != nullptr) {
        if (tmp->data != -1 && tmp->data == k) {
            Node* hold = new Node;
            hold->data = tmp->data;
            tmp->data = -1;
            hold->next = color;
            color = hold;
            return index - minus;
        }
        else {
            index++;
            if (tmp->data == -1)
                minus++;
        }
        tmp = tmp->next;
    }
    return -1;
}

void AnswerQuery(Node* & color, vector<int> query) {
    for (int i = 0; i < query.size(); ++i) {
        cout << findIndex(color,query[i]) << " ";
    }
    cout << endl;
}

// int findPos(vector<int> color, int k) {
//     for (int i = 0; i < color.size(); ++i)
//         if (color[i] == k)
//             return i;
//     return -1;
// }

// void AnswerQuery(vector<int> color, vector<int> query) {
//     for (int i = 0; i < query.size(); ++i) {
//         int pos = findPos(color,query[i]);
//         cout << pos + 1 << " ";
//         color.insert(color.begin(), color[pos]);
//         color.erase(color.begin()+pos+1);
//     }
//     cout << endl;
// }

int main() {
    int n, q, hold;
    cin >> n >> q;
    vector<int> query;
    Node* color = new Node, *tmp = color;
    cin >> color->data;
    for (int i = 1; i < n; ++i) {
        tmp->next = new Node;
        tmp = tmp->next;
        cin >> tmp->data;
        tmp->next == nullptr;
    }
    // for (int i = 0; i < n; ++i) {
    //     cin >> hold;
    //     color.push_back(hold);
    // }
    for (int i = 0; i < q; ++i) {
        cin >> hold;
        query.push_back(hold);
    }
    
    AnswerQuery(color, query);

    return 0;
}