[NOIP2017]图书管理员 (nowcoder.com)
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N =2e5+10,M=1e3+10;
int a[N];
int n,q;
int check(int l,int x)
{int tmp=pow(10,l);for(int i=1;i<=n;i++){if(a[i]%tmp==x){cout<<a[i]<<endl;return 0;}}cout<<-1<<endl;return 0;
}
signed main()
{std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cin>>n>>q;for(int i=1;i<=n;i++)cin>>a[i];//book bianmasort(a+1,a+1+n);while(q--){int l,x;cin>>l>>x;check(l,x);}return 0;
}