#include <bits/stdc++.h>
using namespace std;
long long fpow(long long n, long long k, long long p = 1000000007) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
long long inv(long long a, long long p = 1000000007) {
  return fpow(a, p - 2, p);
}
long long Sqrt(long long x) {
  if (x == 0 || x == 1) return x;
  long long start = 1, end = x, ans;
  while (start <= end) {
    long long mid = (start + end) / 2;
    if (mid * mid == x) return mid;
    if (mid * mid < x) {
      start = mid + 1;
      ans = mid;
    } else
      end = mid - 1;
  }
  return ans;
}
long long power(long long x, long long y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void in(long long &no) {
  bool neg = false;
  register long long c;
  no = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) no = no * 10 + c - 48;
  if (neg) no *= -1;
}
int main() {
  int n, i, t;
  long long z;
  cin >> n >> t;
  int a[n];
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
  }
  deque<int> dq;
  int max1 = a[0], itr = 0;
  dq.push_back(a[0]);
  for (long long i = (1); i < (n); i++) {
    dq.push_back(a[i]);
    if (a[i] > max1) {
      max1 = a[i];
      itr = i;
    }
  }
  pair<int, int> p1[itr + 1];
  int x, y;
  for (long long i = (0); i < (itr + 1); i++) {
    x = dq.front();
    dq.pop_front();
    y = dq.front();
    dq.pop_front();
    p1[i] = make_pair(x, y);
    dq.push_front(max(x, y));
    dq.push_back(min(x, y));
  }
  pair<int, int> p2[n];
  for (long long i = (0); i < (n); i++) {
    x = dq.front();
    dq.pop_front();
    y = dq.front();
    dq.pop_front();
    p2[i] = make_pair(x, y);
    dq.push_front(max(x, y));
    dq.push_back(min(x, y));
  }
  while (t--) {
    cin >> z;
    z--;
    if (z < itr + 1)
      cout << p1[z].first << " " << p1[z].second;
    else {
      z = z - itr - 1;
      z = z % (n - 1);
      cout << p2[z].first << " " << p2[z].second;
    }
    cout << "\n";
  }
  return 0;
}
