#include <bits/stdc++.h>
using namespace std;
const int MX = 1 << 22;
const int MOD = 1000000007;
const int64_t mod2 = 1000000007 * 1LL * 1000000007;
double strtod(string second) {
  stringstream str(second);
  double number = 0;
  str >> number;
  return number;
}
int64_t strtoll(string second) {
  stringstream str(second);
  int64_t number = 0;
  str >> number;
  return number;
}
int64_t ff[50005], M[30005][505];
int64_t vis[100005], pref[100005];
int64_t cnt, n, m, second, t;
vector<int> gr[100005];
int dn[1005][1005];
char str[1001][1001];
int dx[] = {-1, 1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, -1, 1, 1, -1, -1, 1};
bool valid(int x, int y) {
  if (x >= 0 && x < n && y >= 0 & y < m) return true;
  return false;
}
int64_t dis[200005], dis2[200005];
vector<pair<int64_t, int64_t>> grp[200005];
void dijkstra(int64_t v) {
  set<pair<int64_t, int64_t>> second;
  second.insert({0, v});
  dis[v] = 0;
  while (!second.empty()) {
    auto ff = *second.begin();
    second.erase(second.begin());
    for (auto i : grp[ff.second]) {
      if (ff.second == n + 1) {
        if (dis[ff.second] + i.second < dis[i.first]) {
          second.erase({dis[i.first], i.first});
          dis[i.first] = dis[ff.second] + i.second;
          second.insert({dis[i.first], i.first});
        }
      } else {
        if (dis[ff.second] + 2 * 1LL * i.second < dis[i.first]) {
          second.erase({dis[i.first], i.first});
          dis[i.first] = dis[ff.second] + 2 * 1LL * i.second;
          second.insert({dis[i.first], i.first});
        }
      }
    }
  }
}
int Rank[100001], parent[100001], Color[100001][101];
int qu[200001], qq[200001], pai[200001], qar[200001];
int xxx[101], yyy[101];
int findSet(int x) {
  return (parent[x] = (parent[x] == x) ? x : findSet(parent[x]));
}
int isSameSet(int x, int y) { return findSet(x) == findSet(y); }
void unionSet(int x, int y) {
  if (!isSameSet(x, y)) {
    int xx = findSet(x), yy = findSet(y);
    if (Rank[xx] > Rank[yy]) {
      parent[yy] = xx;
    } else {
      parent[xx] = yy;
    }
    if (Rank[xx] == Rank[yy]) Rank[yy]++;
  }
}
bool isBetween(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  int crossproduct = (c.second - a.second) * (b.first - a.first) -
                     (c.first - a.first) * (b.second - a.second);
  if (abs(crossproduct) != 0) return false;
  int dotproduct = (c.first - a.first) * (b.first - a.first) +
                   (c.second - a.second) * (b.second - a.second);
  if (dotproduct < 0) return false;
  int squaredlengthba = (b.first - a.first) * (b.first - a.first) +
                        (b.second - a.second) * (b.second - a.second);
  if (dotproduct > squaredlengthba) return false;
  return true;
}
int64_t fast_pow(int64_t a, int64_t b, int64_t mod) {
  int64_t res = 1;
  while (b) {
    if (b & 1) {
      res = (1LL * res * a) % mod;
    }
    a = (1LL * a * a) % mod;
    b >>= 1;
  }
  return res;
}
int64_t MMI_fermat(int64_t n, int64_t MOD) { return fast_pow(n, MOD - 2, MOD); }
struct trie {
  int val;
  trie *child[2];
};
trie *get_node() {
  trie *new_node = new trie();
  new_node->val = 0;
  new_node->child[0] = NULL;
  new_node->child[1] = NULL;
  return new_node;
}
void add(trie *root, int key) {
  trie *head = root;
  for (int i = 29; i >= 0; i--) {
    bool bit = (key & (1 << i));
    if (head->child[bit] == NULL) {
      head->child[bit] = get_node();
    }
    head = head->child[bit];
  }
  head->val = key;
}
int get_Min(trie *root, int key) {
  trie *head = root;
  for (int i = 29; i >= 0; i--) {
    bool bit = (key & (1 << i));
    if (head->child[bit] != NULL) {
      head = head->child[bit];
    } else if (head->child[1 ^ bit] != NULL) {
      head = head->child[1 ^ bit];
    }
  }
  return key ^ (head->val);
}
int get_Max(trie *root, int key) {
  trie *head = root;
  for (int i = 29; i >= 0; i--) {
    bool bit = (key & (1 << i));
    if (head->child[1 ^ bit] != NULL) {
      head = head->child[1 ^ bit];
    } else if (head->child[bit] != NULL) {
      head = head->child[bit];
    }
  }
  return key ^ (head->val);
}
const int ALPHABET_SIZE = 26;
struct TrieNode {
  struct TrieNode *children[ALPHABET_SIZE];
  bool isEndOfWord;
};
struct TrieNode *getNode() {
  struct TrieNode *pNode = new TrieNode();
  pNode->isEndOfWord = false;
  for (int i = 0; i < ALPHABET_SIZE; i++) pNode->children[i] = NULL;
  return pNode;
}
void insert(struct TrieNode *root, string key) {
  struct TrieNode *pCrawl = root;
  for (int i = 0; i < key.length(); i++) {
    int index = key[i] - 'a';
    if (!pCrawl->children[index]) pCrawl->children[index] = getNode();
    pCrawl = pCrawl->children[index];
  }
  pCrawl->isEndOfWord = true;
}
bool search(struct TrieNode *root, string key) {
  struct TrieNode *pCrawl = root;
  for (int i = 0; i < key.length(); i++) {
    int index = key[i] - 'a';
    if (!pCrawl->children[index]) return false;
    pCrawl = pCrawl->children[index];
  }
  return (pCrawl != NULL && pCrawl->isEndOfWord);
}
int st[MX];
pair<int, int> ar[MX];
int fans[MX];
void build_st(int l, int r, int idx) {
  if (l == r) {
    st[idx] = 1;
    return;
  }
  int mid = (l + r) / 2;
  build_st(l, mid, 2 * idx);
  build_st(mid + 1, r, 2 * idx + 1);
  st[idx] = st[2 * idx] + st[2 * idx + 1];
}
void print(int idx, int n) {
  if (2 * idx >= 2 * n) {
    cout << fans[idx] << " ";
    return;
  }
  print(idx * 2, n);
  print(2 * idx + 1, n);
}
void inversion_count(int second, int e, int ar[], int &ans) {
  if (second >= e) return;
  int mid = (second + e) / 2;
  inversion_count(second, mid, ar, ans);
  inversion_count(mid + 1, e, ar, ans);
  int i = second, j = mid + 1;
  int aux[e - second + 1];
  int k = 0;
  while (i <= mid && j <= e) {
    if (ar[i] <= ar[j]) {
      aux[k] = ar[i];
      k++;
      i++;
    } else {
      ans += (mid - i + 1);
      aux[k] = ar[j];
      k++;
      j++;
    }
  }
  while (i <= mid) {
    aux[k] = ar[i];
    k++;
    i++;
  }
  while (j <= e) {
    aux[k] = ar[j];
    k++;
    j++;
  }
  int l = second;
  for (int i = 0; i < k; i++) {
    ar[l] = aux[i];
    l++;
  }
}
struct Node {
  char c;
  int v;
  Node *left;
  Node *right;
  Node(char c1, int v1) : c(c1), v(v1), left(NULL), right(NULL) {}
};
void inorder(Node *root) {
  if (!root) return;
  inorder(root->left);
  cout << (root->c) << " ";
  inorder(root->right);
}
void fun(Node *root, map<int, vector<int>> &mp, int l) {
  if (!root) return;
  mp[l].push_back(root->c);
  fun(root->right, mp, l);
  fun(root->left, mp, l + 1);
}
void preorder(Node *root) {
  if (!root) return;
  cout << (root->v) << " ";
  preorder(root->left);
  preorder(root->right);
}
int func(Node *&root, int &ans) {
  if (!root) return 0;
  int left = func(root->left, ans);
  int right = func(root->right, ans);
  ans = max(ans, root->v + left + right);
  return root->v + max(left, right);
}
int ksum(Node *root, int second, int k, vector<int> &v,
         vector<vector<int>> &ans) {
  if (!root) return 0;
  second += root->v;
  v.push_back(root->v);
  ksum(root->left, second + root->v, k, v, ans);
  ksum(root->right, second + root->v, k, v, ans);
  v.pop_back();
}
void fuck(Node *root, int k, vector<int> &v, vector<vector<int>> &ans) {
  if (!root) return;
  if (root->v == k) {
    v.push_back(root->v);
    ans.push_back(v);
    return;
  }
  v.push_back(root->v);
  fuck(root->left, k, v, ans);
  fuck(root->right, k, v, ans);
  v.pop_back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int ar[n], ar2[m];
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = 0; i < m; i++) cin >> ar2[i];
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ar2[j] == ar[i]) {
        ans.push_back(ar[i]);
        break;
      }
    }
  }
  if ((int)ans.size() == 0)
    cout << "";
  else {
    for (int i = 0; i < (int)ans.size(); i++) {
      cout << ans[i] << " ";
    }
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.

Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 10) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.

The next line contains n distinct space-separated integers x_1, x_2, …, x_n (0 ≤ x_i ≤ 9) representing the sequence.

The next line contains m distinct space-separated integers y_1, y_2, …, y_m (0 ≤ y_i ≤ 9) — the keys with fingerprints.

Output

In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.

Examples

Input

7 3
3 5 7 1 6 2 8
1 2 7


Output

7 1 2


Input

4 4
3 4 1 0
0 1 7 9


Output

1 0

Note

In the first example, the only digits with fingerprints are 1, 2 and 7. All three of them appear in the sequence you know, 7 first, then 1 and then 2. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.

In the second example digits 0, 1, 7 and 9 have fingerprints, however only 0 and 1 appear in the original sequence. 1 appears earlier, so the output is 1 0. Again, the order is important.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MX = 1 << 22;
const int MOD = 1000000007;
const int64_t mod2 = 1000000007 * 1LL * 1000000007;
double strtod(string second) {
  stringstream str(second);
  double number = 0;
  str >> number;
  return number;
}
int64_t strtoll(string second) {
  stringstream str(second);
  int64_t number = 0;
  str >> number;
  return number;
}
int64_t ff[50005], M[30005][505];
int64_t vis[100005], pref[100005];
int64_t cnt, n, m, second, t;
vector<int> gr[100005];
int dn[1005][1005];
char str[1001][1001];
int dx[] = {-1, 1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, -1, 1, 1, -1, -1, 1};
bool valid(int x, int y) {
  if (x >= 0 && x < n && y >= 0 & y < m) return true;
  return false;
}
int64_t dis[200005], dis2[200005];
vector<pair<int64_t, int64_t>> grp[200005];
void dijkstra(int64_t v) {
  set<pair<int64_t, int64_t>> second;
  second.insert({0, v});
  dis[v] = 0;
  while (!second.empty()) {
    auto ff = *second.begin();
    second.erase(second.begin());
    for (auto i : grp[ff.second]) {
      if (ff.second == n + 1) {
        if (dis[ff.second] + i.second < dis[i.first]) {
          second.erase({dis[i.first], i.first});
          dis[i.first] = dis[ff.second] + i.second;
          second.insert({dis[i.first], i.first});
        }
      } else {
        if (dis[ff.second] + 2 * 1LL * i.second < dis[i.first]) {
          second.erase({dis[i.first], i.first});
          dis[i.first] = dis[ff.second] + 2 * 1LL * i.second;
          second.insert({dis[i.first], i.first});
        }
      }
    }
  }
}
int Rank[100001], parent[100001], Color[100001][101];
int qu[200001], qq[200001], pai[200001], qar[200001];
int xxx[101], yyy[101];
int findSet(int x) {
  return (parent[x] = (parent[x] == x) ? x : findSet(parent[x]));
}
int isSameSet(int x, int y) { return findSet(x) == findSet(y); }
void unionSet(int x, int y) {
  if (!isSameSet(x, y)) {
    int xx = findSet(x), yy = findSet(y);
    if (Rank[xx] > Rank[yy]) {
      parent[yy] = xx;
    } else {
      parent[xx] = yy;
    }
    if (Rank[xx] == Rank[yy]) Rank[yy]++;
  }
}
bool isBetween(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  int crossproduct = (c.second - a.second) * (b.first - a.first) -
                     (c.first - a.first) * (b.second - a.second);
  if (abs(crossproduct) != 0) return false;
  int dotproduct = (c.first - a.first) * (b.first - a.first) +
                   (c.second - a.second) * (b.second - a.second);
  if (dotproduct < 0) return false;
  int squaredlengthba = (b.first - a.first) * (b.first - a.first) +
                        (b.second - a.second) * (b.second - a.second);
  if (dotproduct > squaredlengthba) return false;
  return true;
}
int64_t fast_pow(int64_t a, int64_t b, int64_t mod) {
  int64_t res = 1;
  while (b) {
    if (b & 1) {
      res = (1LL * res * a) % mod;
    }
    a = (1LL * a * a) % mod;
    b >>= 1;
  }
  return res;
}
int64_t MMI_fermat(int64_t n, int64_t MOD) { return fast_pow(n, MOD - 2, MOD); }
struct trie {
  int val;
  trie *child[2];
};
trie *get_node() {
  trie *new_node = new trie();
  new_node->val = 0;
  new_node->child[0] = NULL;
  new_node->child[1] = NULL;
  return new_node;
}
void add(trie *root, int key) {
  trie *head = root;
  for (int i = 29; i >= 0; i--) {
    bool bit = (key & (1 << i));
    if (head->child[bit] == NULL) {
      head->child[bit] = get_node();
    }
    head = head->child[bit];
  }
  head->val = key;
}
int get_Min(trie *root, int key) {
  trie *head = root;
  for (int i = 29; i >= 0; i--) {
    bool bit = (key & (1 << i));
    if (head->child[bit] != NULL) {
      head = head->child[bit];
    } else if (head->child[1 ^ bit] != NULL) {
      head = head->child[1 ^ bit];
    }
  }
  return key ^ (head->val);
}
int get_Max(trie *root, int key) {
  trie *head = root;
  for (int i = 29; i >= 0; i--) {
    bool bit = (key & (1 << i));
    if (head->child[1 ^ bit] != NULL) {
      head = head->child[1 ^ bit];
    } else if (head->child[bit] != NULL) {
      head = head->child[bit];
    }
  }
  return key ^ (head->val);
}
const int ALPHABET_SIZE = 26;
struct TrieNode {
  struct TrieNode *children[ALPHABET_SIZE];
  bool isEndOfWord;
};
struct TrieNode *getNode() {
  struct TrieNode *pNode = new TrieNode();
  pNode->isEndOfWord = false;
  for (int i = 0; i < ALPHABET_SIZE; i++) pNode->children[i] = NULL;
  return pNode;
}
void insert(struct TrieNode *root, string key) {
  struct TrieNode *pCrawl = root;
  for (int i = 0; i < key.length(); i++) {
    int index = key[i] - 'a';
    if (!pCrawl->children[index]) pCrawl->children[index] = getNode();
    pCrawl = pCrawl->children[index];
  }
  pCrawl->isEndOfWord = true;
}
bool search(struct TrieNode *root, string key) {
  struct TrieNode *pCrawl = root;
  for (int i = 0; i < key.length(); i++) {
    int index = key[i] - 'a';
    if (!pCrawl->children[index]) return false;
    pCrawl = pCrawl->children[index];
  }
  return (pCrawl != NULL && pCrawl->isEndOfWord);
}
int st[MX];
pair<int, int> ar[MX];
int fans[MX];
void build_st(int l, int r, int idx) {
  if (l == r) {
    st[idx] = 1;
    return;
  }
  int mid = (l + r) / 2;
  build_st(l, mid, 2 * idx);
  build_st(mid + 1, r, 2 * idx + 1);
  st[idx] = st[2 * idx] + st[2 * idx + 1];
}
void print(int idx, int n) {
  if (2 * idx >= 2 * n) {
    cout << fans[idx] << " ";
    return;
  }
  print(idx * 2, n);
  print(2 * idx + 1, n);
}
void inversion_count(int second, int e, int ar[], int &ans) {
  if (second >= e) return;
  int mid = (second + e) / 2;
  inversion_count(second, mid, ar, ans);
  inversion_count(mid + 1, e, ar, ans);
  int i = second, j = mid + 1;
  int aux[e - second + 1];
  int k = 0;
  while (i <= mid && j <= e) {
    if (ar[i] <= ar[j]) {
      aux[k] = ar[i];
      k++;
      i++;
    } else {
      ans += (mid - i + 1);
      aux[k] = ar[j];
      k++;
      j++;
    }
  }
  while (i <= mid) {
    aux[k] = ar[i];
    k++;
    i++;
  }
  while (j <= e) {
    aux[k] = ar[j];
    k++;
    j++;
  }
  int l = second;
  for (int i = 0; i < k; i++) {
    ar[l] = aux[i];
    l++;
  }
}
struct Node {
  char c;
  int v;
  Node *left;
  Node *right;
  Node(char c1, int v1) : c(c1), v(v1), left(NULL), right(NULL) {}
};
void inorder(Node *root) {
  if (!root) return;
  inorder(root->left);
  cout << (root->c) << " ";
  inorder(root->right);
}
void fun(Node *root, map<int, vector<int>> &mp, int l) {
  if (!root) return;
  mp[l].push_back(root->c);
  fun(root->right, mp, l);
  fun(root->left, mp, l + 1);
}
void preorder(Node *root) {
  if (!root) return;
  cout << (root->v) << " ";
  preorder(root->left);
  preorder(root->right);
}
int func(Node *&root, int &ans) {
  if (!root) return 0;
  int left = func(root->left, ans);
  int right = func(root->right, ans);
  ans = max(ans, root->v + left + right);
  return root->v + max(left, right);
}
int ksum(Node *root, int second, int k, vector<int> &v,
         vector<vector<int>> &ans) {
  if (!root) return 0;
  second += root->v;
  v.push_back(root->v);
  ksum(root->left, second + root->v, k, v, ans);
  ksum(root->right, second + root->v, k, v, ans);
  v.pop_back();
}
void fuck(Node *root, int k, vector<int> &v, vector<vector<int>> &ans) {
  if (!root) return;
  if (root->v == k) {
    v.push_back(root->v);
    ans.push_back(v);
    return;
  }
  v.push_back(root->v);
  fuck(root->left, k, v, ans);
  fuck(root->right, k, v, ans);
  v.pop_back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int ar[n], ar2[m];
  for (int i = 0; i < n; i++) cin >> ar[i];
  for (int i = 0; i < m; i++) cin >> ar2[i];
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ar2[j] == ar[i]) {
        ans.push_back(ar[i]);
        break;
      }
    }
  }
  if ((int)ans.size() == 0)
    cout << "";
  else {
    for (int i = 0; i < (int)ans.size(); i++) {
      cout << ans[i] << " ";
    }
  }
  return 0;
}

```