CF994A

A. Fingerprints

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 nn and mm (1≤n,m≤101≤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 nn distinct space-separated integers x1,x2,…,xnx1,x2,…,xn (0≤xi≤90≤xi≤9) representing the sequence.

The next line contains mm distinct space-separated integers y1,y2,…,ymy1,y2,…,ym (0≤yi≤90≤yi≤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

Copy

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

output

Copy

7 1 2

input

Copy

4 4
3 4 1 0
0 1 7 9

output

Copy

1 0

Note

In the first example, the only digits with fingerprints are 11, 22 and 77. All three of them appear in the sequence you know, 77 first, then 11 and then 22. 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 00, 11, 77 and 99 have fingerprints, however only 00 and 11 appear in the original sequence. 11 appears earlier, so the output is 1 0. Again, the order is important.


其实题意很简单,看懂题了就知道怎么做了,就看这个指纹有没有在上面输出过就直接输出答案就行

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctype.h>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <sstream>
#define ll unsigned long long
#define re return //最近在尝试一种毒瘤的写法

using namespace std;

int n, m;
int num[20];
int xu[20];
int zhi_wen[20];

int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> xu[i];
    }

    for (int i = 1; i <= m; i++){
        cin >> zhi_wen[i];
        num[zhi_wen[i]]++;
    }

    for (int i = 1; i <= n; i++){
        if(num[xu[i]])
            cout << xu[i] << " ";
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值