#include <bits/stdc++.h>
using namespace std;
const long long N = 300005;
int v[100100], n, q;
long long m;
pair<int, int> p[100100];
vector<int> a;
int ce(int a, int b) { return (a + b - 1) / b; }
int main() {
  scanf("%d %d", &n, &q);
  int ma = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &v[i]);
    if (i) {
      p[i] = {ma, v[i]};
      if (v[i] > ma) {
        if (ma > 0) a.push_back(ma);
        ma = v[i];
      } else
        a.push_back(v[i]);
    } else
      ma = v[i];
  }
  for (int i = 0; i < q; ++i) {
    scanf("%lld", &m);
    if (m < n) {
      int h = (int)m;
      printf("%d %d\n", p[h].first, p[h].second);
    } else {
      m %= (n - 1);
      int h = (int)m;
      printf("%d %d\n", ma, a[h ? h - 1 : n - 2]);
    }
  }
  return 0;
}
