#include<iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int n, q;
int a[N];
int main()
{
cin >> n >> q;//表示数组长度和询问个数
for (int i = 0;i < n;i++)cin >> a[i];
while (q--) {
int k;
cin >> k;
//二分找左端点
int l = 0, r = n - 1;
while (l < r)
{
int mid = l + r >> 1;
if (a[mid] >= k)r = mid;
else l = mid+1;
}
//左端点存在,找右端点
if (a[l] == k) {
cout << l <<" ";
r = n - 1;
while (l < r) {
int mid = l + r +1 >> 1;// 因为写的是l = mid,所以需要补上1
if (a[mid] <= k)l = mid;
else r = mid-1;
}
cout << l << endl;
}
else cout << "-1 -1" << endl;
}
}