#include <bits/stdc++.h>
using namespace std;
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
const int N = 200005;
int n, q, a[N], ans[N];
int l[N];
int cnt[N];
deque<int> m, mx;
int sdlmgsog[N][2];
array<int, 4> idx[N];
array<int, 3> id2[N];
array<int, 3> operator+(array<int, 3> a, array<int, 3> b) {
  if (max({a[0], a[1], a[2]}) > max({b[0], b[1], b[2]})) return b;
  return a;
}
array<int, 4> operator+(array<int, 4> a, array<int, 4> b) {
  if (max({a[0], a[1], a[2], a[3]}) > max({b[0], b[1], b[2], b[3]})) return b;
  return a;
}
template <class T>
struct segment_tree {
 public:
  vector<T> node;
  vector<T> arr;
  segment_tree(int size, vector<T> ar) {
    node.resize(4 * size);
    arr = ar;
  }
  void build(int l, int r, int curr) {
    int mid = (l + r) / 2;
    if (l == r) {
      node[curr] = arr[l];
      assert(l != 0);
      return;
    }
    build(l, mid, 2 * curr);
    build(mid + 1, r, 2 * curr + 1);
    node[curr] = node[2 * curr] + node[2 * curr + 1];
    return;
  }
  T query(int x, int y, int l, int r, int curr) {
    int mid = (l + r) / 2;
    if (l == x && r == y) return node[curr];
    if (y <= mid) return query(x, y, l, mid, 2 * curr);
    if (x > mid) return query(x, y, mid + 1, r, 2 * curr + 1);
    return query(x, mid, l, mid, 2 * curr) +
           query(mid + 1, y, mid + 1, r, 2 * curr + 1);
  }
};
int32_t main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i < (n + 1); ++i) {
    scanf("%d", &a[i]);
    l[i] = (int)1e9;
  }
  set<int> mex;
  idx[n + 1] = {(int)1e9, 0, 0, 0};
  id2[n + 1] = {(int)1e9, 0, 0};
  for (int i = n + 1 - 1; i >= 1; i--) {
    id2[i] = id2[i + 1];
    idx[i] = idx[i + 1];
    if (a[i] == (a[i + 1])) {
      l[i] = l[i + 1];
      sdlmgsog[i][0] = sdlmgsog[i + 1][0];
      sdlmgsog[i][1] = sdlmgsog[i + 1][1];
      m.push_front(i);
      mx.push_front(i);
    } else {
      while ((int)(m).size() && a[i] < a[m[0]]) {
        cnt[m[0]]++;
        if (cnt[m[0]] == 2) mex.insert(m[0]);
        m.pop_front();
      }
      while ((int)(mx).size() && a[i] > a[mx[0]]) {
        cnt[mx[0]]++;
        if (cnt[mx[0]] == 2) mex.insert(mx[0]);
        mx.pop_front();
      }
      if ((int)(m).size() >= 1) {
        if (a[m[0]] == a[i]) {
          sdlmgsog[i][0] = sdlmgsog[m[0]][0];
        } else
          sdlmgsog[i][0] = m[0];
      } else
        sdlmgsog[i][0] = (int)1e9;
      if ((int)(mx).size() >= 1) {
        if (a[mx[0]] == a[i]) {
          sdlmgsog[i][1] = sdlmgsog[mx[0]][1];
        } else
          sdlmgsog[i][1] = mx[0];
      } else
        sdlmgsog[i][1] = (int)1e9;
      int v = max(sdlmgsog[i][0], sdlmgsog[i][1]);
      if (mex.lower_bound(v) != mex.end()) {
        l[i] = *mex.lower_bound(v);
        auto p = lower_bound(begin(m), end(m), l[i]),
             q = lower_bound(begin(mx), end(mx), l[i]);
        if (p != m.begin() && q != mx.begin()) {
          array<int, 4> ff = {i, *prev(p), *prev(q), l[i]};
          idx[i] = idx[i] + ff;
        }
      }
      if (sdlmgsog[i][0] <= n) {
        auto p = lower_bound(begin(mx), end(mx), sdlmgsog[i][0]);
        if (p != mx.begin()) {
          array<int, 3> ff = {i, *prev(p), sdlmgsog[i][0]};
          id2[i] = id2[i] + ff;
        }
        if (sdlmgsog[sdlmgsog[i][0]][1] <= n) {
          array<int, 3> ff = {i, sdlmgsog[i][0], sdlmgsog[sdlmgsog[i][0]][1]};
          id2[i] = id2[i] + ff;
        }
      }
      if (sdlmgsog[i][1] <= n) {
        auto p = lower_bound(begin(m), end(m), sdlmgsog[i][1]);
        if (p != m.begin()) {
          array<int, 3> ff = {i, *prev(p), sdlmgsog[i][1]};
          id2[i] = id2[i] + ff;
        }
        if (sdlmgsog[sdlmgsog[i][1]][0] <= n) {
          array<int, 3> ff = {i, sdlmgsog[i][1], sdlmgsog[sdlmgsog[i][1]][0]};
          id2[i] = id2[i] + ff;
        }
      }
      m.push_front(i), mx.push_front(i);
    }
  }
  vector<array<int, 3>> aa;
  vector<array<int, 4>> bb;
  aa.push_back({0, 0, 0});
  bb.push_back({0, 0, 0, 0});
  for (int i = 1; i < (n + 1); ++i) aa.push_back(id2[i]), bb.push_back(idx[i]);
  segment_tree<array<int, 4>> A(n + 2, bb);
  segment_tree<array<int, 3>> B(n + 2, aa);
  A.build(1, n, 1);
  B.build(1, n, 1);
  for (int qq = 0; qq < (q); ++qq) {
    int L, R;
    scanf("%d%d", &L, &R);
    array<int, 4> id = A.query(L, R, 1, n, 1);
    if (max({id[0], id[1], id[2], id[3]}) <= R) {
      puts("4");
      sort(begin(id), end(id));
      printf("%d %d %d %d\n", id[0], id[1], id[2], id[3]);
    } else {
      array<int, 3> id = B.query(L, R, 1, n, 1);
      if (max({id[0], id[1], id[2]}) <= R) {
        puts("3");
        sort(begin(id), end(id));
        printf("%d %d %d\n", id[0], id[1], id[2]);
      } else
        puts("0");
    }
  }
}
