#include <bits/stdc++.h>
using namespace std;
long long int visit[1000001] = {0};
long long int visit1[1000001] = {0};
vector<long long int> adj[1000001];
long long int bfs(long long int g) {
  queue<long long int> q;
  visit[g] = 1;
  q.push(g);
  long long int x = 1;
  while (!q.empty()) {
    long long int f = q.front();
    q.pop();
    for (long long int i = 0; i < adj[f].size(); i++) {
      if (visit[adj[f][i]] == 0) {
        q.push(adj[f][i]);
        x++;
        visit[adj[f][i]] = 1;
      }
    }
  }
  x--;
  queue<long long int> q1;
  visit1[g] = 1;
  q1.push(g);
  if (adj[g].size() != x) return 0;
  while (!q1.empty()) {
    long long int f1 = q1.front();
    q1.pop();
    for (long long int i = 0; i < adj[f1].size(); i++) {
      if (visit1[adj[f1][i]] == 0) {
        q1.push(adj[f1][i]);
        visit1[adj[f1][i]] = 1;
        if (adj[adj[f1][i]].size() != x) return 0;
      }
    }
  }
  return 1;
}
bool sortinrev(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  if (a.first != b.first)
    return (a.first > b.first);
  else
    return (a.second < b.second);
}
long long int power(long long int x, long long int n) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x);
    x = (x * x);
    n = n / 2;
  }
  return result;
}
bool isPrime(long long int k) {
  if (k <= 1) {
    return false;
  }
  if (k == 2) {
    return true;
  }
  if (k % 2 == 0) {
    return false;
  }
  long long int i = 3;
  while (i * i <= k) {
    if (k % i == 0) {
      return false;
    }
    i += 2;
  }
  return true;
}
long long int bin(long long int n) {
  int di = 0;
  while (n) {
    di = di + n % 10;
    n = n / 10;
  }
  return di;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    long long int n, q;
    cin >> n >> q;
    vector<pair<long long int, long long int>> x, y;
    long long int g = 1;
    deque<long long int> d;
    long long int a[n];
    long long int ma = LONG_MIN;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      d.push_back(a[i]);
      ma = max(a[i], ma);
    }
    while (1) {
      if (d.front() == ma) {
        for (long long int j = 0; j < n - 1; j++) {
          long long int c = d.front();
          d.pop_front();
          long long int v = d.front();
          y.push_back({c, v});
          d.pop_front();
          if (c > v) {
            d.push_front(c);
            d.push_back(v);
          } else {
            d.push_front(v);
            d.push_back(c);
          }
        }
        break;
      } else {
        long long int c = d.front();
        d.pop_front();
        long long int v = d.front();
        x.push_back({c, v});
        g++;
        d.pop_front();
        if (c > v) {
          d.push_front(c);
          d.push_back(v);
        } else {
          d.push_front(v);
          d.push_back(c);
        }
      }
    }
    while (q--) {
      long long int m;
      cin >> m;
      if (m < g) {
        cout << x[m - 1].first << " " << x[m - 1].second << "\n";
      } else {
        cout << y[(m - g) % (y.size())].first << " "
             << y[(m - g) % (y.size())].second << "\n";
      }
    }
  }
  return 0;
}
