#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T& a, T b) {
  a = max(a, b);
}
template <typename T>
struct BIT {
  int n;
  vector<T> dat;
  BIT(int n = 0) { initialize(n); }
  void initialize(int nin) {
    n = nin;
    dat.resize(n, 0);
  }
  T sum(int i) {
    T s = 0;
    while (i >= 0) {
      s += dat[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }
  T sum_between(int i, int j) { return sum(j) - sum(i - 1); }
  void plus(int i, T x) {
    while (i < n) {
      dat[i] += x;
      i |= i + 1;
    }
  }
  int lower_bound(T x) {
    if (x < 0) return -1;
    int ret = -1;
    int k = 1;
    while (2 * k <= n) k <<= 1;
    for (; k > 0; k >>= 1) {
      if (ret + k < n && dat[ret + k] < x) {
        x -= dat[ret + k];
        ret += k;
      }
    }
    return ret + 1;
  }
};
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  vector<int> L(Q), R(Q);
  vector<vector<pair<int, int>>> R2LI(N);
  for (int i = 0; i < Q; i++) {
    scanf("%d %d", &L[i], &R[i]);
    L[i]--;
    R[i]--;
    R2LI[R[i]].emplace_back(L[i], i);
  }
  vector<vector<int>> ans(Q);
  for (int t = 0; t < 2; t++) {
    vector<int> l(N, -1), r(N, N);
    vector<int> pos;
    for (int i = 0; i < N; i++) {
      while (pos.size() && A[pos.back()] >= A[i]) pos.pop_back();
      if (pos.size()) l[i] = pos.back();
      pos.push_back(i);
    }
    pos.clear();
    for (int i = N - 1; i >= 0; i--) {
      while (pos.size() && A[pos.back()] >= A[i]) pos.pop_back();
      if (pos.size()) r[i] = pos.back();
      pos.push_back(i);
    }
    vector<vector<int>> r2v(N + 1, {-1});
    for (int i = 0; i < N; i++) chmax(r2v[r[i]], {l[i], i, r[i]});
    vector<int> mx = {-1};
    for (int i = 0; i < N; i++) {
      chmax(mx, r2v[i]);
      for (auto [ql, idx] : R2LI[i])
        if (ql <= mx[0]) ans[idx] = mx;
    }
    for (int& a : A) a *= -1;
  }
  {
    vector<int> up, dn;
    BIT<int> bit(N);
    vector<vector<int>> r2v(N + 1, {-1});
    for (int i = 0; i < N; i++) {
      while (up.size() && A[up.back()] < A[i]) {
        bit.plus(up.back(), 1);
        up.pop_back();
      }
      while (dn.size() && A[dn.back()] > A[i]) {
        bit.plus(dn.back(), 1);
        dn.pop_back();
      }
      int pt_up = partition_point(up.begin(), up.end(),
                                  [&](int j) { return A[j] != A[i]; }) -
                  up.begin() - 1;
      int pt_dn = partition_point(dn.begin(), dn.end(),
                                  [&](int j) { return A[j] != A[i]; }) -
                  dn.begin() - 1;
      if (pt_up >= 0 && pt_dn >= 0) {
        int x = min(up[pt_up], dn[pt_dn]);
        if (bit.sum(x) > 0) {
          int l = bit.lower_bound(bit.sum(x));
          int m1 = *lower_bound(up.begin(), up.end(), l);
          int m2 = *lower_bound(dn.begin(), dn.end(), l);
          if (m1 > m2) swap(m1, m2);
          r2v[i] = {l, m1, m2, i};
        }
      }
      if (i < N - 1) {
        if (A[i] > A[i + 1]) up.push_back(i);
        if (A[i] < A[i + 1]) dn.push_back(i);
      }
    }
    vector<int> mx = {-1};
    for (int i = 0; i < N; i++) {
      chmax(mx, r2v[i]);
      for (auto [ql, idx] : R2LI[i])
        if (ql <= mx[0]) ans[idx] = mx;
    }
  }
  for (auto& v : ans) {
    printf("%d\n", int(v.size()));
    for (int a : v) printf("%d ", a + 1);
    printf("\n");
  }
  return 0;
}
