#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int N = (int)1e5 + 7;
int a[N];
deque<int> q;
pair<int, int> ans[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (1); i < (n + 1); ++i) {
    scanf("%d", &a[i]);
    q.push_back(a[i]);
  }
  for (int i = (1); i < (n + 1); ++i) {
    int x = q.front();
    q.pop_front();
    int y = q.front();
    q.pop_front();
    ans[i] = make_pair(x, y);
    if (x < y) swap(x, y);
    q.push_front(x);
    q.push_back(y);
  }
  for (int i = (0); i < (n); ++i) {
    a[i] = q.front();
    q.pop_front();
  }
  for (int i = (0); i < (m); ++i) {
    long long t;
    scanf("%lld", &t);
    if (t <= n)
      printf("%d %d\n", ans[t].first, ans[t].second);
    else {
      t -= n;
      t %= (n - 1);
      if (t == 0) t = n - 1;
      printf("%d %d\n", a[0], a[t]);
    }
  }
  return 0;
}
