#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int maxn = 200000 + 10;
const int maxm = 100 + 10;
const int apsz = 26;
const int inf = 1e9;
int a[maxn];
int n, q;
vector<int> four[maxn];
int len[maxn];
vector<int> three[maxn];
inline void getFour() {
  vector<int> inc, dec, cnt;
  cnt = vector<int>(n + 1, 0);
  set<int> notin;
  for (auto i = (n); i >= (1); --i) {
    for (; !dec.empty();) {
      int r = dec.back();
      if (a[r] > a[i]) {
        if (--cnt[r] == 0) notin.insert(r);
        dec.pop_back();
      } else
        break;
    }
    for (; !inc.empty();) {
      int r = inc.back();
      if (a[r] < a[i]) {
        if (--cnt[r] == 0) notin.insert(r);
        inc.pop_back();
      } else
        break;
    }
    if (!dec.empty() && !inc.empty() && a[dec[0]] != a[i] &&
        a[inc[0]] != a[i]) {
      int v, x, y, z, l, r;
      l = 0, r = ((int)(dec).size()) - 1;
      while (l < r) {
        int mid = l + (r - l + 1) / 2;
        if (a[dec[mid]] < a[i])
          l = mid;
        else
          r = mid - 1;
      }
      x = l;
      l = 0, r = ((int)(inc).size()) - 1;
      while (l < r) {
        int mid = l + (r - l + 1) / 2;
        if (a[inc[mid]] > a[i])
          l = mid;
        else
          r = mid - 1;
      }
      y = l;
      auto it = notin.upper_bound(max(dec[x], inc[y]));
      if (it != notin.end()) {
        int z = *it;
        l = 0, r = y;
        while (l < r) {
          int mid = r - (r - l + 1) / 2;
          if (inc[mid] < z)
            r = mid;
          else
            l = mid + 1;
        }
        y = inc[l];
        l = 0, r = x;
        while (l < r) {
          int mid = r - (r - l + 1) / 2;
          if (dec[mid] < z)
            r = mid;
          else
            l = mid + 1;
        }
        x = dec[l];
        four[i][0] = i, four[i][1] = min(x, y);
        four[i][2] = max(x, y), four[i][3] = z;
      }
    }
    if (four[i].back() > four[i + 1].back()) {
      four[i] = four[i + 1];
    }
    cnt[i] = 2;
    inc.push_back(i);
    dec.push_back(i);
  }
}
inline void getThreeInc() {
  vector<int> inc;
  set<int> notin;
  for (auto i = (n); i >= (1); --i) {
    for (; !inc.empty();) {
      int r = inc.back();
      if (a[r] < a[i]) {
        notin.insert(r);
        inc.pop_back();
      } else
        break;
    }
    if (!inc.empty() && a[inc[0]] > a[i]) {
      int x, y, z, l, r;
      l = 0, r = ((int)(inc).size()) - 1;
      while (l < r) {
        int mid = l + (r - l + 1) / 2;
        if (a[inc[mid]] > a[i])
          l = mid;
        else
          r = mid - 1;
      }
      x = i, y = l, z = n + 1;
      auto it = notin.upper_bound(inc[l]);
      if (it != notin.end()) {
        z = (*it);
        l = 0, r = y;
        while (l < r) {
          int mid = r - (r - l + 1) / 2;
          if (inc[mid] < z)
            r = mid;
          else
            l = mid + 1;
        }
        y = inc[l];
      }
      if (three[i].back() > z)
        three[i][0] = i, three[i][1] = y, three[i][2] = z;
    }
    if (three[i].back() > three[i + 1].back()) three[i] = three[i + 1];
    inc.push_back(i);
  }
}
inline void getThreeDec() {
  vector<int> dec;
  set<int> notin;
  for (auto i = (n); i >= (1); --i) {
    for (; !dec.empty();) {
      int r = dec.back();
      if (a[r] > a[i]) {
        notin.insert(r);
        dec.pop_back();
      } else
        break;
    }
    if (!dec.empty() && a[dec[0]] < a[i]) {
      int x, y, z, l, r;
      l = 0, r = ((int)(dec).size()) - 1;
      while (l < r) {
        int mid = l + (r - l + 1) / 2;
        if (a[dec[mid]] < a[i])
          l = mid;
        else
          r = mid - 1;
      }
      x = i, y = l, z = n + 1;
      auto it = notin.upper_bound(dec[l]);
      if (it != notin.end()) {
        z = (*it);
        l = 0, r = y;
        while (l < r) {
          int mid = r - (r - l + 1) / 2;
          if (dec[mid] < z)
            r = mid;
          else
            l = mid + 1;
        }
        y = dec[l];
      }
      if (three[i].back() > z)
        three[i][0] = i, three[i][1] = y, three[i][2] = z;
    }
    if (three[i].back() > three[i + 1].back()) three[i] = three[i + 1];
    dec.push_back(i);
  }
}
inline void getThree() {
  getThreeInc();
  getThreeDec();
}
inline void solve() {
  for (auto i = (1); i <= (n + 1); ++i) {
    for (auto j = (0); j < (3); ++j) three[i].push_back(n + 1);
  }
  for (auto i = (1); i <= (n + 1); ++i) {
    for (auto j = (0); j < (4); ++j) four[i].push_back(n + 1);
  }
  getFour();
  getThree();
  for (auto i = (0); i < (q); ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    vector<int> ans;
    if (four[l].back() <= r)
      ans = four[l];
    else if (three[l].back() <= r)
      ans = three[l];
    printf("%d\n", ((int)(ans).size()));
    for (auto e : ans) {
      printf("%d ", e);
    }
    puts("");
  }
}
int main(void) {
  scanf("%d", &(n));
  scanf("%d", &(q));
  for (auto i = (1); i <= (n); ++i) scanf("%d", &(a[i]));
  solve();
  return 0;
}
