include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
const int N = 1e5 + 1;
int a[N];
int n, q, k;
bool binary_search(int x) {
int l = 0, r = n - 1;
while (l <= r) {
int mid = (l + r) / 2;
if (a[mid] == x) {
return true;
}
if (a[mid] < x) {
l = mid + 1;
} else {
r = mid - 1;
}
}
return false;
}
int binary_1(int x) {
int l = 0, r = n - 1;
while (l <= r) {
int mid = (l + r) / 2;
if (a[mid] >= x) {
r = mid - 1;
} else {
l = mid + 1;
}
}
return l;
}
int binary_2(int x) {
int l = 0, r = n - 1;
while (l <= r) {
int mid = (l + r) / 2;
if (a[mid] > x) {
r = mid - 1;
} else {
l = mid + 1;
}
}
return l - 1;
}
int main() {
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i <= q; i++) {
cin >> k;
if (binary_search(k)) {
cout << binary_1(k) << " " << binary_2(k) << endl;
}
else {
cout << -1 << " " << -1 << endl;
}
}
return 0;
}