#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300010;
int n, m, maxx = 0, num = 0, ans[MAXN];
deque<long long> q;
struct node {
  int r, l;
} t[MAXN];
void solve() {
  while (1) {
    int x = q.front();
    q.pop_front();
    int y = q.front();
    q.pop_front();
    if (x == maxx) {
      q.push_front(y);
      for (int i = 1; i <= n - 1; i++) {
        y = q.front();
        q.pop_front();
        ans[i] = y;
      }
      break;
    } else {
      num++;
      t[num].l = x;
      t[num].r = y;
      if (x > y) {
        q.push_front(x);
        q.push_back(y);
      } else {
        q.push_front(y);
        q.push_back(x);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    maxx = max(a, maxx);
    q.push_back(a);
  }
  solve();
  for (int i = 0; i < m; i++) {
    long long c;
    cin >> c;
    if (c <= num)
      cout << t[c].l << " " << t[c].r << endl;
    else {
      c -= num;
      c %= (n - 1);
      if (c == 0) c = n - 1;
      cout << maxx << " " << ans[c] << endl;
    }
  }
  return 0;
}
