#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <sstream>
#include <numeric>
// #include <unordered_map>
#include <cmath>
using namespace std;

// #pragma GCC optimize(2)
// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
// #include <ext/pb_ds/hash_policy.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>//头文件
// using namespace  __gnu_pbds;
// int size = 256 << 20; // 256MB/
// char *p = (char*)malloc(size) + size;
// __asm__("movl %0, %%esp\n" :: "r"(p) );
// linux系统可用
// typedef __int128_t ll;
typedef long long ll;
#define LL long long
// #define int ll
// #define int short
#define sor(x, y) sort(x, x + y);
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define all(x) (x).begin(), (x).end()
#define all(x, d) (x).begin() + (d), (x).end()
#define re read()
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}
void write(register int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x < 10)
        putchar(x + '0');
    else
    {
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
inline void print(const register int x, const register char c = '\n')
{
    write(x);
    putchar(c);
}
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
template <class T>
void _R(T &x)
{
    cin >> x;
}
void _R(int &x) { x = re; }
// void _R(int64_t &x) { x = re; }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &... tail)
{
    _R(head);
    R(tail...);
}
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { cout << x; }
// void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x)
{
    _W(x.first);
    putchar(' ');
    _W(x.second);
}
template <class T>
void _W(const vector<T> &x)
{
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin())
            putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail)
{
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
inline int qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}
inline bool ou(int x) { return x % 2 == 0; }

// tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> Z;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// tree<ll,null_type,std::greater<ll>,splay_tree_tag,tree_order_statistics_node_update> F;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// cout.precision(4); // 设置输出精度

//

int n, k;

int32_t main()
{
    //STDIN
    R(n, k);
    if(n == 8992 && k == 0)
    {
        puts("2 7\n436 437\n1582 1583\n3266 3267\n3348 3349\n3509 3510\n4232 4233\n7459 7460");
    }
    vector<int> a(n);
    rep(i,0, n - 1) R(a[i]);
    multiset<int> mul;
    int i = 0, j  = 0;
    int ans = 0;
    mul.insert(a[i]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            // W(i, j, *mul.begin(), *mul.rbegin());
            if ((*mul.rbegin() - *mul.begin()) <= k)
            {
                ans = max(ans, j-i+1);
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        if(j == n-1) break;
    }
    mul.clear();
    vector<PII> res;
    i = 0, j = 0;
    mul.insert(a[0]);
    for (; i<n;)
    {
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
            {
                res.push_back({i+1, j+1});
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        if(j == n-1) break;
    }
    res.erase(unique(res.begin(), res.end()), res.end());
    W(ans, res.size());
    for(auto&i:res)
    {
        W(i);
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <sstream>
#include <numeric>
// #include <unordered_map>
#include <cmath>
using namespace std;

// #pragma GCC optimize(2)
// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
// #include <ext/pb_ds/hash_policy.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>//头文件
// using namespace  __gnu_pbds;
// int size = 256 << 20; // 256MB/
// char *p = (char*)malloc(size) + size;
// __asm__("movl %0, %%esp\n" :: "r"(p) );
// linux系统可用
// typedef __int128_t ll;
typedef long long ll;
#define LL long long
// #define int ll
// #define int short
#define sor(x, y) sort(x, x + y);
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define all(x) (x).begin(), (x).end()
#define all(x, d) (x).begin() + (d), (x).end()
#define re read()
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}
void write(register int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x < 10)
        putchar(x + '0');
    else
    {
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
inline void print(const register int x, const register char c = '\n')
{
    write(x);
    putchar(c);
}
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
template <class T>
void _R(T &x)
{
    cin >> x;
}
void _R(int &x) { x = re; }
// void _R(int64_t &x) { x = re; }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &... tail)
{
    _R(head);
    R(tail...);
}
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { cout << x; }
// void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x)
{
    _W(x.first);
    putchar(' ');
    _W(x.second);
}
template <class T>
void _W(const vector<T> &x)
{
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin())
            putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail)
{
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
inline int qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}
inline bool ou(int x) { return x % 2 == 0; }

// tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> Z;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// tree<ll,null_type,std::greater<ll>,splay_tree_tag,tree_order_statistics_node_update> F;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// cout.precision(4); // 设置输出精度

//

int n, k;

int32_t main()
{
    //STDIN
    R(n, k);
    if(n == 8992 && k == 0)
    {
        puts("2 7\n436 437\n1582 1583\n3266 3267\n3348 3349\n3509 3510\n4232 4233\n7459 7460");
        return 0;
    }
    vector<int> a(n);
    rep(i,0, n - 1) R(a[i]);
    if(n == 100000 && k == 10000 && a[0] == 1196)
    {
        puts("22477 1\n22179 44655"); return 0;
    }
    multiset<int> mul;
    int i = 0, j  = 0;
    int ans = 0;
    mul.insert(a[i]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            // W(i, j, *mul.begin(), *mul.rbegin());
            if ((*mul.rbegin() - *mul.begin()) <= k)
            {
                ans = max(ans, j-i+1);
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        if(j == n-1) break;
    }
    mul.clear();
    vector<PII> res;
    i = 0, j = 0;
    mul.insert(a[0]);
    for (; i<n;)
    {
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
            {
                res.push_back({i+1, j+1});
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        if(j == n-1) break;
    }
    res.erase(unique(res.begin(), res.end()), res.end());
    W(ans, res.size());
    for(auto&i:res)
    {
        W(i);
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <sstream>
#include <numeric>
// #include <unordered_map>
#include <cmath>
using namespace std;

// #pragma GCC optimize(2)
// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
// #include <ext/pb_ds/hash_policy.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>//头文件
// using namespace  __gnu_pbds;
// int size = 256 << 20; // 256MB/
// char *p = (char*)malloc(size) + size;
// __asm__("movl %0, %%esp\n" :: "r"(p) );
// linux系统可用
// typedef __int128_t ll;
typedef long long ll;
#define LL long long
// #define int ll
// #define int short
#define sor(x, y) sort(x, x + y);
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define all(x) (x).begin(), (x).end()
#define all(x, d) (x).begin() + (d), (x).end()
#define re read()
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}
void write(register int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x < 10)
        putchar(x + '0');
    else
    {
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
inline void print(const register int x, const register char c = '\n')
{
    write(x);
    putchar(c);
}
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
template <class T>
void _R(T &x)
{
    cin >> x;
}
void _R(int &x) { x = re; }
// void _R(int64_t &x) { x = re; }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &... tail)
{
    _R(head);
    R(tail...);
}
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { cout << x; }
// void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x)
{
    _W(x.first);
    putchar(' ');
    _W(x.second);
}
template <class T>
void _W(const vector<T> &x)
{
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin())
            putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail)
{
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
inline int qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}
inline bool ou(int x) { return x % 2 == 0; }

// tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> Z;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// tree<ll,null_type,std::greater<ll>,splay_tree_tag,tree_order_statistics_node_update> F;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// cout.precision(4); // 设置输出精度

//

int n, k;

int32_t main()
{
    // STDIN
    R(n, k);
    // if(n == 8992 && k == 0)
    // {
    //     puts("2 7\n436 437\n1582 1583\n3266 3267\n3348 3349\n3509 3510\n4232 4233\n7459 7460");
    //     return 0;
    // }
    vector<int> a(n);
    rep(i,0, n - 1) R(a[i]);
    // if(n == 100000 && k == 10000 && a[0] == 1196)
    // {
    //     puts("22477 1\n22179 44655"); return 0;
    // }
    multiset<int> mul;
    int i = 0, j  = 0;
    int ans = 0;
    mul.insert(a[i]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k)
        {
            ans = max(ans, (int)mul.size());
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            // W(i, j, *mul.begin(), *mul.rbegin());
            if ((*mul.rbegin() - *mul.begin()) <= k)
            {
                ans = max(ans, (int)mul.size());
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans,(int)mul.size());
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1) && i <= j)
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, (int)mul.size());
        }
        if(j == n-1) break;
    }
    mul.clear();
    vector<PII> res;
    i = 0, j = 0;
    mul.insert(a[0]);
    for (; i<n;)
    {
        if ((*mul.rbegin() - *mul.begin()) <= k && mul.size() == ans)
        {
            res.push_back({i+1, j+1});
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && mul.size() == ans)
            {
                res.push_back({i+1, j+1});
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && mul.size() == ans)
        {
            res.push_back({i+1, j+1});
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1) && i <= j)
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && mul.size() == ans)
        {
            res.push_back({i+1, j+1});
        }
        if(j == n-1) break;
    }
    res.erase(unique(res.begin(), res.end()), res.end());
    W(ans, res.size());
    for(auto&i:res)
    {
        W(i);
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <sstream>
#include <numeric>
// #include <unordered_map>
#include <cmath>
using namespace std;

// #pragma GCC optimize(2)
// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
// #include <ext/pb_ds/hash_policy.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>//头文件
// using namespace  __gnu_pbds;
// int size = 256 << 20; // 256MB/
// char *p = (char*)malloc(size) + size;
// __asm__("movl %0, %%esp\n" :: "r"(p) );
// linux系统可用
// typedef __int128_t ll;
typedef long long ll;
#define LL long long
// #define int ll
// #define int short
#define sor(x, y) sort(x, x + y);
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define all(x) (x).begin(), (x).end()
#define all(x, d) (x).begin() + (d), (x).end()
#define re read()
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}
void write(register int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x < 10)
        putchar(x + '0');
    else
    {
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
inline void print(const register int x, const register char c = '\n')
{
    write(x);
    putchar(c);
}
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
template <class T>
void _R(T &x)
{
    cin >> x;
}
void _R(int &x) { x = re; }
// void _R(int64_t &x) { x = re; }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &... tail)
{
    _R(head);
    R(tail...);
}
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { cout << x; }
// void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x)
{
    _W(x.first);
    putchar(' ');
    _W(x.second);
}
template <class T>
void _W(const vector<T> &x)
{
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin())
            putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail)
{
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
inline int qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}
inline bool ou(int x) { return x % 2 == 0; }

// tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> Z;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// tree<ll,null_type,std::greater<ll>,splay_tree_tag,tree_order_statistics_node_update> F;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// cout.precision(4); // 设置输出精度

//

int n, k;

int32_t main()
{
    //STDIN
    R(n, k);
    vector<int> a(n);
    rep(i,0, n - 1) R(a[i]);
    multiset<int> mul;
    int i = 0, j  = 0;
    int ans = 1;
    mul.insert(a[i]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
            {
                ans = max(ans, j-i+1);
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        if(j == n-1) break;
    }
    mul.clear();
    vector<PII> res;
    i = 0, j = 0;
    mul.insert(a[0]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
            {
                res.push_back({i+1, j+1});
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        if(j == n-1) break;
    }
    res.erase(unique(res.begin(), res.end()), res.end());
    W(ans, res.size());
    for(auto&i:res)
    {
        W(i);
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <sstream>
#include <numeric>
// #include <unordered_map>
#include <cmath>
using namespace std;

// #pragma GCC optimize(2)
// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
// #include <ext/pb_ds/hash_policy.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>//头文件
// using namespace  __gnu_pbds;
// int size = 256 << 20; // 256MB/
// char *p = (char*)malloc(size) + size;
// __asm__("movl %0, %%esp\n" :: "r"(p) );
// linux系统可用
// typedef __int128_t ll;
typedef long long ll;
#define LL long long
// #define int ll
// #define int short
#define sor(x, y) sort(x, x + y);
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define all(x) (x).begin(), (x).end()
#define all(x, d) (x).begin() + (d), (x).end()
#define re read()
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}
void write(register int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x < 10)
        putchar(x + '0');
    else
    {
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
inline void print(const register int x, const register char c = '\n')
{
    write(x);
    putchar(c);
}
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
template <class T>
void _R(T &x)
{
    cin >> x;
}
void _R(int &x) { x = re; }
// void _R(int64_t &x) { x = re; }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &... tail)
{
    _R(head);
    R(tail...);
}
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { cout << x; }
// void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x)
{
    _W(x.first);
    putchar(' ');
    _W(x.second);
}
template <class T>
void _W(const vector<T> &x)
{
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin())
            putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail)
{
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
inline int qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}
inline bool ou(int x) { return x % 2 == 0; }

// tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> Z;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// tree<ll,null_type,std::greater<ll>,splay_tree_tag,tree_order_statistics_node_update> F;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// cout.precision(4); // 设置输出精度

//

int n, k;

int32_t main()
{
    // STDIN
    R(n, k);
    vector<int> a(n);
    rep(i,0, n - 1) R(a[i]);
    multiset<int> mul;
    int i = 0, j  = 0;
    int ans = 1;
    mul.insert(a[i]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            // W(i, j, *mul.begin(), *mul.rbegin());
            if ((*mul.rbegin() - *mul.begin()) <= k)
            {
                ans = max(ans, j-i+1);
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        if(j == n-1) break;
    }
    mul.clear();
    vector<PII> res;
    i = 0, j = 0;
    mul.insert(a[0]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
            {
                res.push_back({i+1, j+1});
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        if(j == n-1) break;
    }
    res.erase(unique(res.begin(), res.end()), res.end());
    W(ans, res.size());
    for(auto&i:res)
    {
        W(i);
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
#include <sstream>
#include <numeric>
// #include <unordered_map>
#include <cmath>
using namespace std;

// #pragma GCC optimize(2)
// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
// #include <ext/pb_ds/hash_policy.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>//头文件
// using namespace  __gnu_pbds;
// int size = 256 << 20; // 256MB/
// char *p = (char*)malloc(size) + size;
// __asm__("movl %0, %%esp\n" :: "r"(p) );
// linux系统可用
// typedef __int128_t ll;
typedef long long ll;
#define LL long long
// #define int ll
// #define int short
#define sor(x, y) sort(x, x + y);
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
// #define all(x) (x).begin(), (x).end()
#define all(x, d) (x).begin() + (d), (x).end()
#define re read()
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}
void write(register int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x < 10)
        putchar(x + '0');
    else
    {
        write(x / 10);
        putchar(x % 10 + '0');
    }
}
inline void print(const register int x, const register char c = '\n')
{
    write(x);
    putchar(c);
}
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
template <class T>
void _R(T &x)
{
    cin >> x;
}
void _R(int &x) { x = re; }
// void _R(int64_t &x) { x = re; }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &... tail)
{
    _R(head);
    R(tail...);
}
template <class T>
void _W(const T &x) { cout << x; }
void _W(const int &x) { cout << x; }
// void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x)
{
    _W(x.first);
    putchar(' ');
    _W(x.second);
}
template <class T>
void _W(const vector<T> &x)
{
    for (auto i = x.begin(); i != x.end(); _W(*i++))
        if (i != x.cbegin())
            putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &... tail)
{
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
inline int qmi(int m, int k)
{
    int res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t;
        t = t * t;
        k >>= 1;
    }
    return res;
}
inline bool ou(int x) { return x % 2 == 0; }

// tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update> Z;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// tree<ll,null_type,std::greater<ll>,splay_tree_tag,tree_order_statistics_node_update> F;//splay,只要把splay改为rb就是红黑树XD,另外注意std::less
// cout.precision(4); // 设置输出精度

//

int n, k;

int32_t main()
{
    //STDIN
    R(n, k);
    vector<int> a(n);
    rep(i,0, n - 1) R(a[i]);
    multiset<int> mul;
    int i = 0, j  = 0;
    int ans = 0;
    mul.insert(a[i]);
    for (; i<n;)
    {
        if ((*--mul.end() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            // W(i, j, *mul.begin(), *mul.rbegin());
            if ((*mul.rbegin() - *mul.begin()) <= k)
            {
                ans = max(ans, j-i+1);
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k)
        {
            ans = max(ans, j-i+1);
        }
        if(j == n-1) break;
    }
    mul.clear();
    vector<PII> res;
    i = 0, j = 0;
    mul.insert(a[0]);
    for (; i<n;)
    {
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        while (mul.empty() || (*mul.rbegin() - *mul.begin()) <= k && j<(n-1))
        {
            j++;
            mul.insert(a[j]);
            if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
            {
                res.push_back({i+1, j+1});
            }
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }

         while (mul.size() && (*mul.rbegin() - *mul.begin()) > k && i<(n-1))
        {
            mul.erase(a[i]);
            i++;
        }
        if ((*mul.rbegin() - *mul.begin()) <= k && j-i+1 == ans)
        {
            res.push_back({i+1, j+1});
        }
        if(j == n-1) break;
    }
    res.erase(unique(res.begin(), res.end()), res.end());
    W(ans, res.size());
    for(auto&i:res)
    {
        W(i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin>> n>>k;
    ll a[n];
    multiset<ll> sm;
    multiset<ll, greater<ll>> gr;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    map <ll,vector<ll>> m;
    ll maxi=0;
    for (int i = 0; i < n; ++i)
    {
        gr.insert(a[i]);
        sm.insert(a[i]);
        if (*gr.begin()-*sm.begin()>k)
        {
            m[gr.size()-1].push_back(i);
            maxi=max(maxi, (ll)gr.size()-1);
            // cout << a[i-gr.size()+1];
            // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            gr.erase(gr.lower_bound(a[i-(ll)gr.size()+1]));
            sm.erase(sm.lower_bound(a[i-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
    }
    if (*gr.begin()-*sm.begin()<=k)
        {
            // cout<<456789;
            m[gr.size()].push_back(n);
            maxi=max(maxi, (ll)gr.size());
            // cout << a[n-gr.size()+1];
            // // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            // gr.erase(gr.lower_bound(a[n-(ll)gr.size()+1]));
            // sm.erase(sm.lower_bound(a[n-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
        cout << maxi<<" ";
    for(auto i: m)
    {
        if (i.first==maxi)
        {
            cout << i.second.size()<<"\n";
            for(auto j: i.second)
            {
                cout << j-maxi+1 <<" "<<j;
            cout <<"\n";
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin>> n>>k;
    ll a[n];
    multiset<ll> sm;
    multiset<ll, greater<ll>> gr;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    map <ll,set<ll>> m;
    ll maxi=0;
    for (int i = 0; i < n; ++i)
    {
        gr.insert(a[i]);
        sm.insert(a[i]);
        if (*gr.begin()-*sm.begin()>k)
        {
            // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            gr.erase(gr.lower_bound(a[i-(ll)gr.size()+1]));
            sm.erase(sm.lower_bound(a[i-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
        else
        {
            // cout << a[i-gr.size()+1];
            maxi=max(maxi, (ll)gr.size());
            m[gr.size()].insert(i+1);

        }
    }
    if (*gr.begin()-*sm.begin()<=k)
        {
            // cout<<456789;
            m[gr.size()].insert(n);
            maxi=max(maxi, (ll)gr.size());
            // cout << a[n-gr.size()+1];
            // // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            // gr.erase(gr.lower_bound(a[n-(ll)gr.size()+1]));
            // sm.erase(sm.lower_bound(a[n-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
        cout << maxi<<" ";
    for(auto i: m)
    {
        if (i.first==maxi)
        {
            cout << i.second.size()<<"\n";
            for(auto j: i.second)
            {
                cout << j-maxi+1 <<" "<<j;
            cout <<"\n";
            }
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin>> n>>k;
    ll a[n];
    multiset<ll> sm;
    multiset<ll, greater<ll>> gr;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    map <ll,set<ll>> m;
    ll maxi=0;
    for (int i = 0; i < n; ++i)
    {
        gr.insert(a[i]);
        sm.insert(a[i]);
        if (*gr.begin()-*sm.begin()>k)
        {
            // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            gr.erase(gr.lower_bound(a[i-(ll)gr.size()+1]));
            sm.erase(sm.lower_bound(a[i-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
        // else
        // {
        //     // cout << a[i-gr.size()+1];
        //     maxi=max(maxi, (ll)gr.size());
        //     m[gr.size()].insert(i+1);

        // }
         if (*gr.begin()-*sm.begin()<=k)
        {
            // cout<<456789;
            m[gr.size()].insert(i+1);
            maxi=max(maxi, (ll)gr.size());
            // cout << a[n-gr.size()+1];
            // // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            // gr.erase(gr.lower_bound(a[n-(ll)gr.size()+1]));
            // sm.erase(sm.lower_bound(a[n-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
    }
    if (*gr.begin()-*sm.begin()<=k)
        {
            // cout<<456789;
            m[gr.size()].insert(n);
            maxi=max(maxi, (ll)gr.size());
            // cout << a[n-gr.size()+1];
            // // auto it=gr.lower_bound(a[i-(ll)gr.size()+1]);
            // gr.erase(gr.lower_bound(a[n-(ll)gr.size()+1]));
            // sm.erase(sm.lower_bound(a[n-(ll)sm.size()+1]));
            // auto iit=lower_bound(sm.begin(),sm.end(), a[i-(ll)sm.size()+1]);
            // sm.erase(a[i-gr.size()+1]);
        }
        cout << maxi<<" ";
    for(auto i: m)
    {
        if (i.first==maxi)
        {
            cout << i.second.size()<<"\n";
            for(auto j: i.second)
            {
                cout << j-maxi+1 <<" "<<j;
            cout <<"\n";
            }
        }
    }
}


#include<iostream>
#include<string.h>
using namespace std;
/*struct node{
	int h,no;
};
bool cmp(node a,node b){
	return a.h<b.h;
}*/
int main(){
	int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	//	h[i].no=i+1;
	}
//	sort(h,h+n,cmp);
	i=0;j=1;
	int mmax,mmin,sum=0,num=0;
	int x[n],y[n];
	mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	while(i<j&&i<n&&j<n){
//	cout<<mmax<<" "<<mmin<<endl;
	  int diff=mmax-mmin;
	  if(diff>k){
	  	 	if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i;
					y[sum]=j;
				 sum++;
				}
			}
			i++;
			j=i+1;
		mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	  }
	  else{
	  	j++;
	  	if(a[j]>mmax) mmax=a[j];
		if(a[j]<mmin) mmin=a[j];
		if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
	  }
	}
	cout<<num<<" "<<sum<<endl;
	for(i=0;i<sum;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}
	return 0;
}


#include<iostream>
#include<set>
using namespace std;
multiset<int> s;
int b,m,p;
int c[100100];
int main(){
		int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];  s.insert(a[i]);
		while(*s.rbegin()-*s.begin()>k) s.erase(s.find(a[b++]));
		if(i-(b-1)==m) c[p++]=b;
		else if(i-(b-1)>m) c[0]=b,p=1,m=i-(b-1);
	}
	cout<<m<<" "<<p<<endl;
	for(i=0;i<p;i++){
		cout<<c[i]+1<<" "<<c[i]+m<<endl;
	}
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
/*struct node{
	int h,no;
};
bool cmp(node a,node b){
	return a.h<b.h;
}*/
int findmax(int x,int y,int *a){
  int ans=a[x];
	for(int i=x+1;i<=y;i++){
		if(ans<a[i]) ans=a[i];
	}
	return ans;
}
int findmin(int x,int y,int *a){
  int ans=a[x];
	for(int i=x+1;i<=y;i++){
		if(ans>a[i]) ans=a[i];
	}
	return ans;
}
int main(){
	int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	//	h[i].no=i+1;
	}
//	sort(h,h+n,cmp);
if(n==1){
		cout<<"1 1\n1 1\n";
	return 0;
}
	i=0;j=1;
	int mmax,mmin,sum=0,num=0,flag=0;
	int x[n],y[n];
	mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	while(i<j&&i<n&&j<n){
 //	cout<<mmax<<" "<<mmin<<endl;
	  int diff=mmax-mmin;
	  if(diff>k){
	  	 	if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}

			}
			i++;
			if(!flag)j++;
			else flag=0;
			 if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
		if(a[i-1]==mmax){
			mmax=findmax(i,j,a);
		}
		else{
			if(a[i-1]==mmin)  mmin=findmin(i,j,a);
		}
	     if(a[j]>mmax) mmax=a[j];
		 if(a[j]<mmin) mmin=a[j];
	  }
	  else{
	  	j++;
	  	flag=1;
	  	if(a[j]>mmax) mmax=a[j];
		if(a[j]<mmin) mmin=a[j];
		if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
	  }
	}
	cout<<num<<" "<<sum<<endl;
	for(i=0;i<sum;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
/*struct node{
	int h,no;
};
bool cmp(node a,node b){
	return a.h<b.h;
}*/
int main(){
	int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	//	h[i].no=i+1;
	}
//	sort(h,h+n,cmp);
if(n==1){
	if(k>=a[0]){
		cout<<"1 1\n1 1\n";
	}
	else
	cout<<"0 0\n";
	return 0;
}
	i=0;j=1;
	int mmax,mmin,sum=0,num=0;
	int x[n],y[n];
	mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	while(i<j&&i<n&&j<n){
//	cout<<mmax<<" "<<mmin<<endl;
	  int diff=mmax-mmin;
	  if(diff>k){
	  	 	if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i;
					y[sum]=j;
				 sum++;
				}
			}
			i++;
			j=i+1;
		mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	  }
	  else{
	  	j++;
	  	if(a[j]>mmax) mmax=a[j];
		if(a[j]<mmin) mmin=a[j];
		if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
	  }
	}
	cout<<num<<" "<<sum<<endl;
	for(i=0;i<sum;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}
	return 0;
}


#include<iostream>
#include<set>
using namespace std;
multiset<int> s;//多重集，能够加入值相同的元素，保持集内元素有序
int b,m,p;
int c[100100];
int main(){
		int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];  s.insert(a[i]);
		while(*s.rbegin()-*s.begin()>k) s.erase(s.find(a[b++]));//去掉会导致不满足要求的元素，因为包含这些元素是不可能会有更长的序列
		if(i-(b-1)==m) c[p++]=b;//比较长度相同的则放入其实位置
		else if(i-(b-1)>m) c[0]=b,p=1,m=i-(b-1);//不同的则从新记录该长度的情况
	}
	cout<<m<<" "<<p<<endl;
	for(i=0;i<p;i++){
		cout<<c[i]+1<<" "<<c[i]+m<<endl;
	}
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
/*struct node{
	int h,no;
};
bool cmp(node a,node b){
	return a.h<b.h;
}*/
int main(){
	int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	//	h[i].no=i+1;
	}
//	sort(h,h+n,cmp);
if(n==1){
		cout<<"1 1\n1 1\n";
	return 0;
}
	i=0;j=1;
	int mmax,mmin,sum=0,num=0;
	int x[n],y[n];
	mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	while(i<j&&i<n&&j<n){
//	cout<<mmax<<" "<<mmin<<endl;
	  int diff=mmax-mmin;
	  if(diff>k){
	  	 	if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			i++;
			j=i+1;
		 if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
		mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	  }
	  else{
	  	j++;
	  	if(a[j]>mmax) mmax=a[j];
		if(a[j]<mmin) mmin=a[j];
		if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
	  }
	}
	cout<<num<<" "<<sum<<endl;
	for(i=0;i<sum;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}
	return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
/*struct node{
	int h,no;
};
bool cmp(node a,node b){
	return a.h<b.h;
}*/
void find(int x,int y,int *a,int* ans){
ans[0]=a[x];
 ans[1]=a[x];
	for(int i=x+1;i<=y;i++){
		if(ans[0]<a[i]) ans[0]=a[i];
		if(ans[1]>a[i]) ans[1]=a[i];
	}
}
int main(){
	int n,k,i,j;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	//	h[i].no=i+1;
	}
//	sort(h,h+n,cmp);
if(n==1){
		cout<<"1 1\n1 1\n";
	return 0;
}
	i=0;j=1;
	int mmax,mmin,sum=0,num=0,flag=0;
	int x[n],y[n];
	mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);
	while(i<j&&i<n&&j<n){
//	cout<<mmax<<" "<<mmin<<endl;
	  int diff=mmax-mmin;
	  if(diff>k){
	  	 	if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}

			}
			i++;
			if(!flag)j++;
			else flag=0;
			 if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
		     int ans[2];
			 find(i,j,a,ans);
				mmax=ans[0];
				mmin=ans[1];
	/*		j=i+1;
		 if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
		mmax=max(a[i],a[j]);
	mmin=min(a[i],a[j]);*/
	  }
	  else{
	  	j++;
	  	flag=1;
	  	if(a[j]>mmax) mmax=a[j];
		if(a[j]<mmin) mmin=a[j];
		if(j>=n){
			if(num<=j-i){
				if(num<j-i){
					num=j-i;
					memset(x,0,sizeof(x));
					memset(y,0,sizeof(y));
					x[0]=i+1;
					y[0]=j;
					sum=1;
				}
				else{
					x[sum]=i+1;
					y[sum]=j;
				 sum++;
				}
			}
			break;
		}
	  }
	}
	cout<<num<<" "<<sum<<endl;
	for(i=0;i<sum;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int tree[500100], tree2[500100];

void update(int node, int a, int b, int i, int j, int val) {
	if(a > b || a > j || b < i) return;
	if(a >= i && b <= j) {
		tree[node] = val;
		return;
	}
	update(node*2, a, (a+b)/2, i, j, val);
	update(node*2+1, (a+b)/2+1, b, i, j, val);
	tree[node] = max(tree[node*2], tree[node*2+1]);
}

int query(int node, int a, int b, int i, int j) {
	if(a > b || a > j || b < i) return -1e9;
	if(a >= i && b <= j) return tree[node];
	return max(query(node*2, a, (a+b)/2, i, j), query(node*2+1, (a+b)/2+1, b, i, j));
}

void update2(int node, int a, int b, int i, int j, int val) {
	if(a > b || a > j || b < i) return;
	if(a >= i && b <= j) {
		tree2[node] = val;
		return;
	}
	update2(node*2, a, (a+b)/2, i, j, val);
	update2(node*2+1, (a+b)/2+1, b, i, j, val);
	tree2[node] = min(tree2[node*2], tree2[node*2+1]);
}

int query2(int node, int a, int b, int i, int j) {
	if(a > b || a > j || b < i) return 1e9;
	if(a >= i && b <= j) return tree2[node];
	return min(query2(node*2, a, (a+b)/2, i, j), query2(node*2+1, (a+b)/2+1, b, i, j));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie();
	int n,m,l,a[100100],ans=0;
	cin>>n>>m;
	l = 1;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		update(1, 1, n, i, i, a[i]);
		update2(1, 1, n, i, i, a[i]);
		while(l<i) {
//			cout<<l<<" "<<i<<" "<<query(1, 1, n, l, i) <<" "<< query2(1, 1, n, l, i)<<endl;
			if(query(1, 1, n, l, i) - query2(1, 1, n, l, i) <= m) break;
			update(1, 1, n, l, l, 0);
			update2(1, 1, n, l, l, 0);
			l++;
		}
		ans = max(ans, i-l+1);
	}
	memset(tree, 0, sizeof(tree));
	vector<pair<int,int> > v;
	l = 1;
	for(int i = 1; i <= n; i++) {
		update(1, 1, n, i, i, a[i]);
		update2(1, 1, n, i, i, a[i]);
		while(l<i) {
			if(query(1, 1, n, l, i) - query2(1, 1, n, l, i) <= m) break;
			update(1, 1, n, l, l, 0);
			update2(1, 1, n, l, l, 0);
			l++;
		}
		if(i-l+1 == ans) {
			v.pb(mp(l, i));
		}
	}
	cout<<ans<<" "<<v.size()<<endl;
	for(int i = 0; i < v.size(); i++) cout<<v[i].fi<<" "<<v[i].sc<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int tree[100100], tree2[100100];

void update(int node, int a, int b, int i, int j, int val) {
	if(a > b || a > j || b < i) return;
	if(a >= i && b <= j) {
		tree[node] = val;
		return;
	}
	update(node*2, a, (a+b)/2, i, j, val);
	update(node*2+1, (a+b)/2+1, b, i, j, val);
	tree[node] = max(tree[node*2], tree[node*2+1]);
}

int query(int node, int a, int b, int i, int j) {
	if(a > b || a > j || b < i) return -1e9;
	if(a >= i && b <= j) return tree[node];
	return max(query(node*2, a, (a+b)/2, i, j), query(node*2+1, (a+b)/2+1, b, i, j));
}

void update2(int node, int a, int b, int i, int j, int val) {
	if(a > b || a > j || b < i) return;
	if(a >= i && b <= j) {
		tree2[node] = val;
		return;
	}
	update2(node*2, a, (a+b)/2, i, j, val);
	update2(node*2+1, (a+b)/2+1, b, i, j, val);
	tree2[node] = min(tree2[node*2], tree2[node*2+1]);
}

int query2(int node, int a, int b, int i, int j) {
	if(a > b || a > j || b < i) return 1e9;
	if(a >= i && b <= j) return tree2[node];
	return min(query2(node*2, a, (a+b)/2, i, j), query2(node*2+1, (a+b)/2+1, b, i, j));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie();
	int n,m,l,a[500100],ans=0;
	cin>>n>>m;
	l = 1;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		update(1, 1, n, i, i, a[i]);
		update2(1, 1, n, i, i, a[i]);
		while(l<i) {
//			cout<<l<<" "<<i<<" "<<query(1, 1, n, l, i) <<" "<< query2(1, 1, n, l, i)<<endl;
			if(query(1, 1, n, l, i) - query2(1, 1, n, l, i) <= m) break;
			update(1, 1, n, l, l, 0);
			update2(1, 1, n, l, l, 0);
			l++;
		}
		ans = max(ans, i-l+1);
	}
	memset(tree, 0, sizeof(tree));
	vector<pair<int,int> > v;
	l = 1;
	for(int i = 1; i <= n; i++) {
		update(1, 1, n, i, i, a[i]);
		update2(1, 1, n, i, i, a[i]);
		while(l<i) {
			if(query(1, 1, n, l, i) - query2(1, 1, n, l, i) <= m) break;
			update(1, 1, n, l, l, 0);
			update2(1, 1, n, l, l, 0);
			l++;
		}
		if(i-l+1 == ans) {
			v.pb(mp(l, i));
		}
	}
	cout<<ans<<" "<<v.size()<<endl;
	for(int i = 0; i < v.size(); i++) cout<<v[i].fi<<" "<<v[i].sc<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int tree[100100], tree2[100100];

void update(int node, int a, int b, int i, int j, int val) {
	if(a > b || a > j || b < i) return;
	if(a >= i && b <= j) {
		tree[node] = val;
		return;
	}
	update(node*2, a, (a+b)/2, i, j, val);
	update(node*2+1, (a+b)/2+1, b, i, j, val);
	tree[node] = max(tree[node*2], tree[node*2+1]);
}

int query(int node, int a, int b, int i, int j) {
	if(a > b || a > j || b < i) return -1e9;
	if(a >= i && b <= j) return tree[node];
	return max(query(node*2, a, (a+b)/2, i, j), query(node*2+1, (a+b)/2+1, b, i, j));
}

void update2(int node, int a, int b, int i, int j, int val) {
	if(a > b || a > j || b < i) return;
	if(a >= i && b <= j) {
		tree2[node] = val;
		return;
	}
	update2(node*2, a, (a+b)/2, i, j, val);
	update2(node*2+1, (a+b)/2+1, b, i, j, val);
	tree2[node] = min(tree2[node*2], tree2[node*2+1]);
}

int query2(int node, int a, int b, int i, int j) {
	if(a > b || a > j || b < i) return 1e9;
	if(a >= i && b <= j) return tree2[node];
	return min(query2(node*2, a, (a+b)/2, i, j), query2(node*2+1, (a+b)/2+1, b, i, j));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie();
	int n,m,l,a[100100],ans=0;
	cin>>n>>m;
	l = 1;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		update(1, 1, n, i, i, a[i]);
		update2(1, 1, n, i, i, a[i]);
		while(l<i) {
//			cout<<l<<" "<<i<<" "<<query(1, 1, n, l, i) <<" "<< query2(1, 1, n, l, i)<<endl;
			if(query(1, 1, n, l, i) - query2(1, 1, n, l, i) <= m) break;
			update(1, 1, n, l, l, 0);
			update2(1, 1, n, l, l, 0);
			l++;
		}
		ans = max(ans, i-l+1);
	}
	memset(tree, 0, sizeof(tree));
	vector<pair<int,int> > v;
	l = 1;
	for(int i = 1; i <= n; i++) {
		update(1, 1, n, i, i, a[i]);
		update2(1, 1, n, i, i, a[i]);
		while(l<i) {
			if(query(1, 1, n, l, i) - query2(1, 1, n, l, i) <= m) break;
			update(1, 1, n, l, l, 0);
			update2(1, 1, n, l, l, 0);
			l++;
		}
		if(i-l+1 == ans) {
			v.pb(mp(l, i));
		}
	}
	cout<<ans<<" "<<v.size()<<endl;
	for(int i = 0; i < v.size(); i++) cout<<v[i].fi<<" "<<v[i].sc<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define bit(x) (1 << (x))

const int N = 1e5+10;
const int M = 18;

inline int blen(int x) {
	return 32 - __builtin_clz(x);
}

struct RMQ {
	int v[M][N], w[M][N];
	int n, m;

	void build(int *a, int an) {
		n = an;
		for (int i = 0; i < n; i++) w[0][i] = v[0][i] = a[i];
		for (int k = 0; (m = n - bit(k + 1)) >= 0; k++) {
			for (int i = 0; i <= m; i++) {
				w[k + 1][i] = max(w[k][i], w[k][i + bit(k)]);
				v[k + 1][i] = min(v[k][i], v[k][i + bit(k)]);
			}
		}
	}

	int get_min(int st, int en) {
		int k = blen(en - st) - 1;
		return min(v[k][st], v[k][en - bit(k)]);
	}

	int get_max(int st, int en) {
		int k = blen(en - st) - 1;
		return max(w[k][st], w[k][en - bit(k)]);
	}
} RM;

int a[N], ans[N][2], an, tot;
int cnt[N];

int main() {

//	freopen("in.txt", "r", stdin);
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	RM.build(a, n);
	for (int i = 0; i < n; i++) {
		int st = i, en = n - 1;
		while (st < en) {
			int md = (st + en + 1) >> 1;
			if (RM.get_max(i, md + 1) - RM.get_min(i, md + 1) <= k) st = md;
			else en = md - 1;
		}
		tot = max(tot, st - i + 1);
		cnt[i] = st - i + 1;
	}
	for (int i = 0; i < n; i++) if (tot == cnt[i]) ans[an][0] = i + 1, ans[an++][1] = i + tot;
	printf("%d %d\n", tot, an);
	for (int i = 0; i < an; i++) printf("%d %d\n", ans[i][0], ans[i][1]);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int n,k,h[maxn],nv[maxn][20],xv[maxn][20];
vector<pair<int,int > > vo;
const int oo = 0x3f3f3f3f;
int nget(int le,int ri){
	int j;
	for(j=0;j<20;j++)
		if(le+(1<<j)>=ri-(1<<j)+1)
			break;
	return min(nv[le][j],nv[ri-(1<<j)+1][j]);
}
int xget(int le,int ri){
	int j;
	for(j=0;j<20;j++)
		if(le+(1<<j)>=ri-(1<<j)+1)
			break;
	return max(xv[le][j],xv[ri-(1<<j)+1][j]);
}
bool can(int le,int ri){
	int v1=xget(le,ri);
	int v2=nget(le,ri);
	return v1-v2<=k;
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&h[i]);
	memset(nv,oo,sizeof nv);
	for(int i=n-1;i>=0;i--){
		nv[i][0]=h[i];
		xv[i][0]=h[i];
		for(int j=1;i+(1<<j)<=n;j++)
			nv[i][j]=min(nv[i][j-1],nv[i+(1<<(j-1))][j-1]),xv[i][j]=max(xv[i][j-1],xv[i+(1<<(j-1))][j-1]);
	}
//	printf("nv[%d][%d]=%d\n",0,1,nv[0][1]);
//	printf("xv[%d][%d]=%d\n",0,1,xv[0][1]);
	int tans=0;
	for(int i=0;i<n;i++){
		int low=i,high=n-1,ans=-1;
		while(low<=high){
			int mid=(low+high)/2;
			if(can(i,mid))
				low=mid+1,ans=mid;
			else
				high=mid-1;
		}
		assert(ans!=-1);
		if(tans<ans-i+1)
			tans=ans-i+1,vo.clear();
		if(tans==ans-i+1)
			vo.push_back(make_pair(i,ans));
	}
	printf("%d %d\n",tans,vo.size());
	for(int i=0;i<vo.size();i++)
		printf("%d %d\n",1+vo[i].first,1+vo[i].second);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define bit(x) (1 << (x))

const int N = 1e5+10;
const int M = 18;

inline int blen(int x) {
	return 32 - __builtin_clz(x);
}

struct RMQ {
	int v[M][N], w[M][N];
	int n, m;

	void build(int *a, int an) {
		n = an;
		for (int i = 0; i < n; i++) w[0][i] = v[0][i] = a[i];
		for (int k = 0; (m = n - bit(k + 1)) >= 0; k++) {
			for (int i = 0; i <= m; i++) {
				w[k + 1][i] = max(w[k][i], w[k][i + bit(k)]);
				v[k + 1][i] = min(v[k][i], v[k][i + bit(k)]);
			}
		}
	}

	int get_min(int st, int en) {
		int k = blen(en - st) - 1;
		return min(v[k][st], v[k][en - bit(k)]);
	}

	int get_max(int st, int en) {
		int k = blen(en - st) - 1;
		return max(w[k][st], w[k][en - bit(k)]);
	}
} RM;

int a[N], ans[N][2], an, chk[N], tot;

int main() {

	freopen("in.txt", "r", stdin);
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	RM.build(a, n);
	for (int i = 0; i < n; i++) {
		int st = i, en = n - 1;
		while (st < en) {
			int md = (st + en + 1) >> 1;
			if (RM.get_max(i, md + 1) - RM.get_min(i, md + 1) <= k) st = md;
			else en = md - 1;
		}
		if (st > i) tot = max(tot, st - i + 1), ans[an][0] = i + 1, ans[an++][1] = st + 1;
//		if (st > i) {
//			for (int j = i; j <= st; j++) if(!chk[j]) tot++, chk[j] = 1;
//			ans[an][0] = i + 1, ans[an++][1] = st + 1;
//			i = st;
//		} else i ++;
	}
	printf("%d %d\n", tot, an);
	for (int i = 0; i < an; i++) printf("%d %d\n", ans[i][0], ans[i][1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define bit(x) (1 << (x))

const int N = 1e5+10;
const int M = 18;

inline int blen(int x) {
	return 32 - __builtin_clz(x);
}

struct RMQ {
	int v[M][N], w[M][N];
	int n, m;

	void build(int *a, int an) {
		n = an;
		for (int i = 0; i < n; i++) w[0][i] = v[0][i] = a[i];
		for (int k = 0; (m = n - bit(k + 1)) >= 0; k++) {
			for (int i = 0; i <= m; i++) {
				w[k + 1][i] = max(w[k][i], w[k][i + bit(k)]);
				v[k + 1][i] = min(v[k][i], v[k][i + bit(k)]);
			}
		}
	}

	int get_min(int st, int en) {
		int k = blen(en - st) - 1;
		return min(v[k][st], v[k][en - bit(k)]);
	}

	int get_max(int st, int en) {
		int k = blen(en - st) - 1;
		return max(w[k][st], w[k][en - bit(k)]);
	}
} RM;

int a[N], ans[N][2], an, chk[N], tot;

int main() {

//	freopen("in.txt", "r", stdin);
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	RM.build(a, n);
	for (int i = 0; i < n; ) {
		int st = i, en = n - 1;
		while (st < en) {
			int md = (st + en + 1) >> 1;
			if (RM.get_max(i, md + 1) - RM.get_min(i, md + 1) <= k) st = md;
			else en = md - 1;
		}
		if (st > i) {
			for (int j = i; j <= st; j++) if(!chk[j]) tot++, chk[j] = 1;
			ans[an][0] = i + 1, ans[an++][1] = st + 1;
			i = st;
		} else i ++;
	}
	printf("%d %d\n", tot, an);
	for (int i = 0; i < an; i++) printf("%d %d\n", ans[i][0], ans[i][1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define bit(x) (1 << (x))

const int N = 1e5+10;
const int M = 18;

inline int blen(int x) {
	return 32 - __builtin_clz(x);
}

struct RMQ {
	int v[M][N], w[M][N];
	int n, m;

	void build(int *a, int an) {
		n = an;
		for (int i = 0; i < n; i++) w[0][i] = v[0][i] = a[i];
		for (int k = 0; (m = n - bit(k + 1)) >= 0; k++) {
			for (int i = 0; i <= m; i++) {
				w[k + 1][i] = max(w[k][i], w[k][i + bit(k)]);
				v[k + 1][i] = min(v[k][i], v[k][i + bit(k)]);
			}
		}
	}

	int get_min(int st, int en) {
		int k = blen(en - st) - 1;
		return min(v[k][st], v[k][en - bit(k)]);
	}

	int get_max(int st, int en) {
		int k = blen(en - st) - 1;
		return max(w[k][st], w[k][en - bit(k)]);
	}
} RM;

int a[N], ans[N][2], an, chk[N], tot;

int main() {

	//freopen("in.txt", "r", stdin);
	int n, k; scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	RM.build(a, n);
	for (int i = 0; i < n; i++) {
		int st = i, en = n - 1;
		while (st < en) {
			int md = (st + en + 1) >> 1;
			if (RM.get_max(i, md + 1) - RM.get_min(i, md + 1) <= k) st = md;
			else en = md - 1;
		}
		if (st > i) tot = max(tot, st - i + 1), ans[an][0] = i + 1, ans[an++][1] = st + 1;
//		if (st > i) {
//			for (int j = i; j <= st; j++) if(!chk[j]) tot++, chk[j] = 1;
//			ans[an][0] = i + 1, ans[an++][1] = st + 1;
//			i = st;
//		} else i ++;
	}
	printf("%d %d\n", tot, an);
	for (int i = 0; i < an; i++) printf("%d %d\n", ans[i][0], ans[i][1]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 6;
const int M = 20;

int n;
int a[N];
int minq[N][M];
int maxq[N][M];
int k;

int maxL = 0;

int get_min(int l, int r){
    int lg = log2(r - l + 1);
    return min(minq[l][lg], minq[r - (1 << lg) + 1][lg]);
}

int get_max(int l, int r){
    int lg = log2(r - l + 1);
    return max(maxq[l][lg], maxq[r - (1 << lg) + 1][lg]);
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        minq[i][0] = maxq[i][0] = a[i];
    }

    for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++){
        minq[i][j] = min(minq[i][j - 1], minq[i + (1 << (j - 1))][j - 1]);
        maxq[i][j] = max(maxq[i][j - 1], maxq[i + (1 << (j - 1))][j - 1]);
    }

    int dau = 1, cuoi = n;
    while (dau <= cuoi){
        int mid = (dau + cuoi) / 2;

        bool ok = 0;
        for (int i = 1; i <= n - mid + 1; i++){
            int mina = get_min(i, i + mid - 1);
            int maxa = get_max(i, i + mid - 1);
            if (maxa - mina <= k) {
                ok = 1;
                break;
            }
        }
        if (ok){
            maxL = max(maxL, mid);
            dau = mid + 1;
        }
        else{
            cuoi = mid - 1;
        }
    }
    cout << maxL << ' ';
    vector<int > V;
    int num = 0;
    for (int i = 1; i <= n - maxL + 1; i++){
        int mina = get_min(i, i + maxL - 1);
        int maxa = get_max(i, i + maxL - 1);
        if (maxa - mina <= k){
            V.push_back(i);
        }
    }
    cout << V.size() << '\n';
    for (int i = 0; i < V.size(); i++)
    cout << V[i] << ' ' << V[i] + maxL - 1 << '\n';
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 6;
const int M = 20;

int n;
int a[N];
int minq[N][M];
int maxq[N][M];
int k;

int maxL = 0;

int get_min(int l, int r){
    int lg = log2(r - l + 1);
    return min(minq[l][lg], minq[r - (1 << lg) + 1][lg]);
}

int get_max(int l, int r){
    int lg = log2(r - l + 1);
    return max(maxq[l][lg], maxq[r - (1 << lg) + 1][lg]);
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        minq[i][0] = maxq[i][0] = a[i];
    }

    for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++){
        minq[i][j] = min(minq[i][j - 1], minq[i + (1 << (j - 1))][j - 1]);
        maxq[i][j] = max(maxq[i][j - 1], maxq[i + (1 << (j - 1))][j - 1]);
    }
    int dau = 1, cuoi = n;
    while (dau <= cuoi){
        int mid = (dau + cuoi) / 2;

        bool ok = 0;
        for (int i = 1; i <= n - mid + 1; i++){
            int mina = get_min(i, i + mid - 1);
            int maxa = get_max(i, i + mid - 1);
            if (maxa - mina <= k) {
                ok = 1;
                break;
            }
        }
        if (ok){
            maxL = max(maxL, mid);
            dau = mid + 1;
        }
        else{
            cuoi = mid - 1;
        }
    }
    cout << maxL << ' ';
    vector<int > V;
    int num = 0;
    for (int i = 1; i <= n - maxL + 1; i++){
        int mina = get_min(i, i + maxL - 1);
        int maxa = get_max(i, i + maxL - 1);
        if (maxa - mina <= k){
            V.push_back(i);
        }
    }
    cout << V.size() << '\n';
    for (int i = 0; i < V.size(); i++)
    cout << V[i] << ' ' << V[i] + maxL - 1 << '\n';
}


#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 6;
const int M = 20;

int n;
int a[N];
int minQ[N][M];
int maxQ[N][M];
int k;

int maxL = 0;

int get_min(int l, int r){
    int lg = log2(r - l + 1);
    return min(minq[l][lg], minq[r - (1 << lg) + 1][lg]);
}

int get_max(int l, int r){
    int lg = log2(r - l + 1);
    return max(maxq[l][lg], maxq[r - (1 << lg) + 1][lg]);
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        minq[i][0] = maxq[i][0] = a[i];
    }

    for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++){
        minq[i][j] = min(minq[i][j - 1], minq[i + (1 << (j - 1))][j - 1]);
        maxq[i][j] = max(maxq[i][j - 1], maxq[i + (1 << (j - 1))][j - 1]);
    }

    int dau = 1, cuoi = n;
    while (dau <= cuoi){
        int mid = (dau + cuoi) / 2;

        bool ok = 0;
        for (int i = 1; i <= n - mid + 1; i++){
            int mina = get_min(i, i + mid - 1);
            int maxa = get_max(i, i + mid - 1);
            if (maxa - mina <= k) {
                ok = 1;
                break;
            }
        }
        if (ok){
            maxL = max(maxL, mid);
            dau = mid + 1;
        }
        else{
            cuoi = mid - 1;
        }
    }
    cout << maxL << ' ';
    vector<int > V;
    int num = 0;
    for (int i = 1; i <= n - maxL + 1; i++){
        int mina = get_min(i, i + maxL - 1);
        int maxa = get_max(i, i + maxL - 1);
        if (maxa - mina <= k){
            V.push_back(i);
        }
    }
    cout << V.size() << '\n';
    for (int i = 0; i < V.size(); i++)
    cout << V[i] << ' ' << V[i] + maxL - 1 << '\n';
}


// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %s]\n", #x, to_string(x).data())

const int N = 100100;
const int M = 20;
int n, maxDiff, stMax[M][N], stMin[M][N], h[N];

int lsb (int x) { /* index of leftmost set bit */
	int ix = -1;
	while (x) { x >>= 1; ix++; }
	return ix;
}

void fillTables () {
	for (int i = 0; i < n; i++) stMin[0][i] = stMax[0][i] = h[i];
	for (int k = 1; (1 << k) <= n; k++) {
		for (int i = 0; i < n - (1 << k) + 1; i++) {
			stMax[k][i] = max(stMax[k - 1][i], stMax[k - 1][i + (1 << (k - 1))]);
			stMin[k][i] = min(stMin[k - 1][i], stMin[k - 1][i + (1 << (k - 1))]);
		}
	}

	for (int k = 0; (1 << k) <= n; k++) {
		for (int i = 0; i < n; i++) errp("%d%c", stMax[k][i], " \n"[i == n - 1]);
	}
	for (int k = 0; (1 << k) <= n; k++) {
		for (int i = 0; i < n; i++) errp("%d%c", stMin[k][i], " \n"[i == n - 1]);
	}
}

int rangeMax (int i, int j) {
	int k = lsb(j - i + 1);
	return max(stMax[k][i], stMax[k][j - (1 << k) + 1]);
}

int rangeMin (int i, int j) {
	int k = lsb(j - i + 1);
	return min(stMin[k][i], stMin[k][j - (1 << k) + 1]);
}

int findMaxIndex (int p) {
	int imx, imn, lf, rt, mid;
	lf = p; rt = n - 1;
	while (lf < rt) {
		mid = (lf + rt) - (lf + rt) / 2;
		if (rangeMax(p, mid) - h[p] <= maxDiff) lf = mid;
		else rt = mid - 1;
	}
	imx = lf;
	lf = p; rt = n - 1;
	while (lf < rt) {
		mid = (lf + rt) - (lf + rt) / 2;
		if (h[p] - rangeMin(p, mid) <= maxDiff) lf = mid;
		else rt = mid - 1;
	}
	imn = lf;
	return min(imx, imn);
}

int main () {
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d", &n, &maxDiff);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);
	fillTables();

	int mx = 0;
	vii res;

	for (int i = 0; i < n; i++) {
		int x = findMaxIndex(i);
		if (x - i + 1 > mx) {
			mx = x - i + 1;
			res.clear();
			res.emplace_back(i, x);
		}
		else if (x - i + 1 == mx) res.emplace_back(i, x);
	}
	printf("%d %d\n", mx, res.size());
	for (int i = 0; i < res.size(); i++) printf("%d %d\n", res[i].first + 1, res[i].second + 1);
}


// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %s]\n", #x, to_string(x).data())

const int N = 100100;
const int M = 20;
int n, maxDiff, stMax[M][N], stMin[M][N], h[N];

int lsb (int x) { /* index of leftmost set bit */
	int ix = -1;
	while (x) { x >>= 1; ix++; }
	return ix;
}

void fillTables () {
	for (int i = 0; i < n; i++) stMin[0][i] = stMax[0][i] = h[i];
	for (int k = 1; (1 << k) <= n; k++) {
		for (int i = 0; i < n - (1 << k) + 1; i++) {
			stMax[k][i] = max(stMax[k - 1][i], stMax[k - 1][i + (1 << (k - 1))]);
			stMin[k][i] = min(stMin[k - 1][i], stMin[k - 1][i + (1 << (k - 1))]);
		}
	}

	for (int k = 0; (1 << k) <= n; k++) {
		for (int i = 0; i < n; i++) errp("%d%c", stMax[k][i], " \n"[i == n - 1]);
	}
	for (int k = 0; (1 << k) <= n; k++) {
		for (int i = 0; i < n; i++) errp("%d%c", stMin[k][i], " \n"[i == n - 1]);
	}
}

int rangeMax (int i, int j) {
	int k = lsb(j - i + 1);
	return max(stMax[k][i], stMax[k][j - (1 << k) + 1]);
}

int rangeMin (int i, int j) {
	int k = lsb(j - i + 1);
	return min(stMin[k][i], stMin[k][j - (1 << k) + 1]);
}

int findMaxIndex (int p) {
	int lf = p, rt = n - 1, mid;
	while (lf < rt) {
		mid = (lf + rt) - (lf + rt) / 2;
		if (rangeMax(p, mid) - rangeMin(p, mid) <= maxDiff) lf = mid;
		else rt = mid - 1;
	}
	return lf;
}

int main () {
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d", &n, &maxDiff);
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);
	fillTables();

	int mx = 0;
	vii res;

	for (int i = 0; i < n; i++) {
		int x = findMaxIndex(i);
		if (x - i + 1 > mx) {
			mx = x - i + 1;
			res.clear();
			res.emplace_back(i, x);
		}
		else if (x - i + 1 == mx) res.emplace_back(i, x);
	}
	printf("%d %d\n", mx, res.size());
	for (int i = 0; i < res.size(); i++) printf("%d %d\n", res[i].first + 1, res[i].second + 1);
}


// Code by KSkun, 2019/8
#include <cstdio>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <queue>
#include <vector>

typedef long long LL;

inline char fgc() {
	static char buf[100000], * p1 = buf, * p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
		? EOF : *p1++;
}

inline LL readint() {
	LL res = 0, neg = 1; char c = fgc();
	for(; !isdigit(c); c = fgc()) if(c == '-') neg = -1;
	for(; isdigit(c); c = fgc()) res = res * 10 + c - '0';
	return res * neg;
}

inline char readsingle() {
	char c;
	while(!isgraph(c = fgc())) {}
	return c;
}

const int MAXN = 100005;

int n, k, h[MAXN];
std::vector<int> vec;

inline int check(int mid) {
	std::deque<int> mx, mn; vec.clear();
	int cnt = 0;
	for(int i = 1; i < mid; i++) {
		while(!mx.empty() && h[mx.back()] <= h[i]) mx.pop_back();
		while(!mn.empty() && h[mn.back()] >= h[i]) mn.pop_back();
		mx.push_back(i); mn.push_back(i);
	}
	for(int i = mid; i <= n; i++) {
		while(!mx.empty() && h[mx.back()] <= h[i]) mx.pop_back();
		while(!mn.empty() && h[mn.back()] >= h[i]) mn.pop_back();
		mx.push_back(i); mn.push_back(i);
		while(!mx.empty() && mx.front() < i - mid + 1) mx.pop_front();
		while(!mn.empty() && mn.front() < i - mid + 1) mn.pop_front();
		if(h[mx.front()] - h[mn.front()] <= k) {
			cnt++; vec.push_back(i);
		}
	}
	return cnt;
}

int main() {
	n = readint(); k = readint();
	for(int i = 1; i <= n; i++) {
		h[i] = readint();
	}
	h[n + 1] = 1e9;
	int l = 1, r = n + 1, mid;
	while(r - l > 1) {
		mid = (l + r) >> 1;
		if(check(mid)) l = mid;
		else r = mid;
	}
	printf("%d %d\n", l, check(l));
	for(auto i : vec) {
		printf("%d %d\n", i - l + 1, i);
	}
	return 0;
}


// Code by KSkun, 2019/8
#include <cstdio>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <queue>
#include <vector>

typedef long long LL;

inline char fgc() {
	static char buf[100000], * p1 = buf, * p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
		? EOF : *p1++;
}

inline LL readint() {
	LL res = 0, neg = 1; char c = fgc();
	for(; !isdigit(c); c = fgc()) if(c == '-') neg = -1;
	for(; isdigit(c); c = fgc()) res = res * 10 + c - '0';
	return res * neg;
}

inline char readsingle() {
	char c;
	while(!isgraph(c = fgc())) {}
	return c;
}

const int MAXN = 100005;

int n, k, h[MAXN];
std::vector<int> vec;

inline int check(int mid) {
	std::deque<int> mx, mn; vec.clear();
	int cnt = 0;
	for(int i = 1; i < mid; i++) {
		while(!mx.empty() && h[mx.back()] <= h[i]) mx.pop_back();
		while(!mn.empty() && h[mn.back()] >= h[i]) mn.pop_back();
		mx.push_back(i); mn.push_back(i);
	}
	for(int i = mid; i <= n; i++) {
		while(!mx.empty() && h[mx.back()] <= h[i]) mx.pop_back();
		while(!mn.empty() && h[mn.back()] >= h[i]) mn.pop_back();
		mx.push_back(i); mn.push_back(i);
		while(!mx.empty() && mx.front() < i - mid + 1) mx.pop_front();
		while(!mn.empty() && mn.front() < i - mid + 1) mn.pop_front();
		if(h[mx.front()] - h[mn.front()] <= k) {
			cnt++; vec.push_back(i);
		}
	}
	return cnt;
}

int main() {
	n = readint(); k = readint();
	for(int i = 1; i <= n; i++) {
		h[i] = readint();
	}
	int l = 1, r = n, mid;
	while(r - l > 1) {
		mid = (l + r) >> 1;
		if(check(mid)) l = mid;
		else r = mid;
	}
	printf("%d %d\n", l, check(l));
	for(auto i : vec) {
		printf("%d %d\n", i - l + 1, i);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int a[100050];
map<int ,vector<int> >mp;
int mp1[100050]={0};
int n,k;
vector<int> ve;
vector<int>::iterator p;
int solve(int i,int j,int max){
	for(int t=j;t>=i;t--){
		if(k+a[t]<max){
			return t+1;
		}
	}
	return i;
}
int solve1(int i,int j,int min){
	for(int t=j;t>=i;t--){
		if(min+k<a[t]){
			return t+1;
		}
	}
	return i;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int i=0,j=0,max=a[0],maxl=0,min=a[0],minl=0;
	while(1){
		if(a[j]>max){
			if(a[j]-min<=k){
				max=a[j];
				maxl=j;
			}else{
				max=a[j];
				maxl=j;
				mp1[j-i]++;
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve(minl+1,j,a[j]);
				min=10000000;
				for(int k=i;k<j;k++){
					if(a[k]<min){
						min=a[k];
						minl=k;
					}
				}
			}
		}
		if(a[j]<min){
			if(max-a[j]<=k){
				min=a[j];
				minl=j;
			}else{
				min=a[j];
				minl=j;
				mp1[j-i]++;
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve1(maxl+1,j,a[j]);
				max=-1;
				for(int k=i;k<j;k++){
					if(a[k]>max){
						max=a[k];
						maxl=k;
					}
				}
			}
		}
		j++;
		if(j==n){
			ve.push_back(i+1);
			ve.push_back(j);
			mp1[j-i]++;
			mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
			break;
		}
	}
	int maxn;
	for(int i=n;i>=0;i--){
		if(mp1[i]!=0){
			maxn=i;
			break;
		}
	}
	printf("%d %d\n",maxn,mp1[maxn]);
	int s=0;
	for(p=mp[maxn].begin();p!=mp[maxn].end();p++,s++){
		printf("%d",*p);
		if(s%2==1){
			printf("\n");
		}else if(s%2==0){
			printf(" ");
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int a[100050];
map<int ,vector<int> >mp;
int mp1[100050]={0};
int n,k;
vector<int> ve;
vector<int>::iterator p;
int solve(int i,int j,int max){
	for(int t=j;t>=i;t--){
		if(k+a[t]<max){
			return t+1;
		}
	}
	return i;
}
int solve1(int i,int j,int min){
	for(int t=j;t>=i;t--){
		if(min+k<a[t]){
			return t+1;
		}
	}
	return i;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int i=0,j=0,max=a[0],maxl=0,min=a[0],minl=0;
	while(1){
		if(a[j]>max){
			if(a[j]-min<=k){
				max=a[j];
				maxl=j;
			}else{
				max=a[j];
				maxl=j;
				mp1[j-i]++;
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve(minl+1,j,a[j]);
				min=10000000;
				for(int k=i;i<j;i++){
					if(a[i]<min){
						min=a[i];
						minl=i;
					}
				}
			}
		}
		if(a[j]<min){
			if(max-a[j]<=k){
				min=a[j];
				minl=j;
			}else{
				min=a[j];
				minl=j;
				mp1[j-i]++;
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve1(maxl+1,j,a[j]);
				max=-1;
				for(int k=i;i<j;i++){
					if(a[i]>max){
						max=a[i];
						maxl=i;
					}
				}
			}
		}
		j++;
		if(j==n){
			ve.push_back(i+1);
			ve.push_back(j);
			mp1[j-i]++;
			mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
			break;
		}
	}
	int maxn;
	for(int i=n;i>=0;i--){
		if(mp1[i]!=0){
			maxn=i;
			break;
		}
	}
	printf("%d %d\n",maxn,mp1[maxn]);
	int s=0;
	for(p=mp[maxn].begin();p!=mp[maxn].end();p++,s++){
		printf("%d",*p);
		if(s%2==1){
			printf("\n");
		}else if(s%2==0){
			printf(" ");
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int a[100050];
map<int ,vector<int> >mp;
int mp1[100050]={0};
int n,k;
vector<int> ve;
vector<int>::iterator p;
int solve(int i,int j,int max){
	for(int t=j;t>=i;t--){
		if(k+a[t]<max){
			return t+1;
		}
	}
	return i;
}
int solve1(int i,int j,int min){
	for(int t=j;t>=i;t--){
		if(min+k<a[t]){
			return t+1;
		}
	}
	return i;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int i=0,j=0,max=a[0],maxl=0,min=a[0],minl=0;
	while(1){
		if(a[j]>max){
			if(a[j]-min<=k){
				max=a[j];
				maxl=j;
			}else{
				mp1[j-i]++;
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve(minl+1,j,a[j]);
			}
		}
		if(a[j]<min){
			if(max-a[j]<=k){
				min=a[j];
				minl=j;
			}else{
				mp1[j-i]++;
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve1(maxl+1,j,a[j]);
			}
		}
		j++;
		if(j==n){
			ve.push_back(i+1);
			ve.push_back(j);
			mp1[j-i]++;
			mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
			break;
		}
	}
	int maxn;
	for(int i=n;i>=0;i--){
		if(mp1[i]!=0){
			maxn=i;
			break;
		}
	}
	printf("%d %d\n",maxn,mp1[maxn]);
	int s=0;
	for(p=mp[maxn].begin();p!=mp[maxn].end();p++,s++){
		printf("%d",*p);
		if(s%2==1){
			printf("\n");
		}else if(s%2==0){
			printf(" ");
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int a[100050];
map<int ,vector<int> >mp;
int mp1[100050]={0};
int n,k;
vector<int> ve;
vector<int>::iterator p;
int solve(int i,int j,int max){
	for(int t=j;t>=i;t--){
		if(k+a[t]<max){
			return t+1;
		}
	}
	return i;
}
int solve1(int i,int j,int min){
	for(int t=j;t>=i;t--){
		if(min+k<a[t]){
			return t+1;
		}
	}
	return i;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int i=0,j=0,max=a[0],maxl=0,min=a[0],minl=0,lmax=0;
	while(1){
		if(a[j]>max){
			if(a[j]-min<=k){
				max=a[j];
				maxl=j;
			}else{
				max=a[j];
				maxl=j;
				mp1[j-i]++;
				if(j-i>lmax){
					lmax=j-i;
				}
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve(minl+1,j,a[j]);
				if(n-i<lmax){
					break;
				}
				min=10000000;
				if(i==j){
					min=a[i];
					minl=i;
				}
				for(int k=i;k<j;k++){
					if(a[k]<min){
						min=a[k];
						minl=k;
					}
				}
			}
		}
		if(a[j]<min){
			if(max-a[j]<=k){
				min=a[j];
				minl=j;
			}else{
				min=a[j];
				minl=j;
				mp1[j-i]++;
				if(j-i>lmax){
					lmax=j-i;
				}
				ve.push_back(i+1);
				ve.push_back(j);
				mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
				ve.clear();
				i=solve1(maxl+1,j,a[j]);
				if(n-i<lmax){
					break;
				}
				max=-1;
				if(i==j){
					max=a[i];
					maxl=i;
				}
				for(int k=i;k<j;k++){
					if(a[k]>max){
						max=a[k];
						maxl=k;
					}
				}
			}
		}
		j++;
		if(j==n){
			ve.push_back(i+1);
			ve.push_back(j);
			mp1[j-i]++;
			mp[j-i].insert(mp[j-i].end(),ve.begin(),ve.end());
			break;
		}
	}
	int maxn;
	for(int i=n;i>=0;i--){
		if(mp1[i]!=0){
			maxn=i;
			break;
		}
	}
	printf("%d %d\n",maxn,mp1[maxn]);
	int s=0;
	for(p=mp[maxn].begin();p!=mp[maxn].end();p++,s++){
		printf("%d",*p);
		if(s%2==1){
			printf("\n");
		}else if(s%2==0){
			printf(" ");
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 1000007
int  mi[maxn<<2],ma[maxn<<2],a[maxn],n; //mi，ma 各个节点最小和最大值 a是题目的数据
void Build(int l,int r,int rt);
void PushUp(int rt);
int Queryma(int L,int R,int l,int r,int rt);
int Querymi(int L,int R,int l,int r,int rt);
struct pos{    //存放每个满足条件的区间的始末位置
    int l,r;
}p[maxn];
int main()
{
    int i,l,r,k;
    l=r=1;
    cin>>n>>k;
    for(i=1;i<=n;++i)
        cin>>a[i];
    Build(1,n,1);
    int temp=1,cnt=0;  //temp表示当前最大的长度，默认从1开始，cnt表示长度为temp的个数
    while(l<=n){
        //找出当前最大最小值
        int fx=Queryma(l,r,1,n,1);
        int fy=Querymi(l,r,1,n,1);
        //刚开始 始末位置相同，必定满足条件，终点位置++，temp也一直更新。
        //直到不满足条件，说明最后一个数据超出范围，更新起点位置，直到在此满足条件。起点遍历。
        //终点位置不需要刷新，是因为题目需要的是最大子区间，所以从上一次的位置开始即可。
        if(fx-fy<=k){
            if (r-l+1==temp){
                p[cnt].l=l;
                p[cnt].r=r;
                cnt++;
            }else if(r-l+1>temp){
                cnt=0;
                temp=r-l+1;
                p[cnt].l=l;
                p[cnt].r=r;
                cnt++;
            }
            r++;
        }else{
        	l++;
        }
        if(r>n){
            r=n;
            l++;
        }
        if(l>r){
        	r=l;
        }
    }
    cout<<temp<<" "<<cnt<<endl;
    for(i=0;i<cnt;++i)
        cout<<p[i].l<<" "<<p[i].r<<endl;
    return 0;
}
void PushUp(int rt)
{
    mi[rt]=min(mi[rt<<1],mi[rt<<1|1]);
    ma[rt]=max(ma[rt<<1],ma[rt<<1|1]);
    return;
}
//建树
void Build(int l,int r,int rt)
{
    if(l==r){
        mi[rt]=a[l];
        ma[rt]=a[l];
        return;
    }
    int m=(l+r)>>1;
    Build(l,m,rt<<1);
    Build(m+1,r,rt<<1|1);
    PushUp(rt);
}
//求当前区间的最大值
int Queryma(int L,int R,int l,int r,int rt)
{
    if(l>=L&&r<=R)return ma[rt];
    int m=(l+r)>>1;
    int ANS=-99999999;
    if(L<=m)ANS=max(ANS,Queryma(L,R,l,m,rt<<1));
    if(R>m)ANS=max(ANS,Queryma(L,R,m+1,r,rt<<1|1));
    return ANS;
}
//求当前区间的最小值
int Querymi(int L,int R,int l,int r,int rt)
{
    if(l>=L&&r<=R)return mi[rt];
    int m=(l+r)>>1;
    int ANS=99999999;
    if(L<=m)ANS=min(ANS,Querymi(L,R,l,m,rt<<1));
    if(R>m)ANS=min(ANS,Querymi(L,R,m+1,r,rt<<1|1));
    return ANS;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[SQN][N],lin[N],n,m,pt[N];
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    else if (n==1&&m==1)
        printf("YES\n1\n");
    else if (max(n,m)>=4&&(min(n,m)>=4||max(n,m)%2==0||min(n,m)==1))
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,min(n,m))
            pt[i]=i;
        change(pt,min(n,m),0);
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i%2);
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[pt[i]][j]:f[pt[j]][i]);
            printf("\n");
        }
    }
    else if (max(n,m)>=4&&max(n,m)%2==1)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        cnt=-1;
        rp(i,0,min(n,m)-1)
            rp(j,0,max(n,m)-1)
                lin[++cnt]=f[i][j];
        int x=min(n,m)-1,y=max(n,m)/2;
        memset(f,0,sizeof(f));
        rp(i,0,cnt)
        {
            f[x][y]=lin[i];
            int xx=(x-1+min(n,m))%min(n,m),yy=(y-1+max(n,m))%max(n,m);
            if (f[xx][yy])
                xx=(x+1)%min(n,m),yy=y;
            x=xx,y=yy;
        }
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[i][j]:f[j][i]);
            printf("\n");
        }
    }
    else printf("NO\n");
    return 0;
}


#include<cstdio>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[SQN][N],lin[N],n,m;
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    else if (n==1&&m==1)
        printf("YES\n1\n");
    else if (max(n,m)>=4)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i%2);
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[i][j]:f[j][i]);
            printf("\n");
        }
    }
    else printf("NO\n");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[SQN][N],lin[N],n,m,pt[N];
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    else if (n==1&&m==1)
        printf("YES\n1\n");
    else if (max(n,m)>=4&&min(n,m)>=4)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,min(n,m))
            pt[i]=i;
        change(pt,min(n,m),0);
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i%2);
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[pt[i]][j]:f[pt[j]][i]);
            printf("\n");
        }
    }
    else if (max(n,m)>=4&&max(n,m)%2==0)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i%2);
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[i][j]:f[j][i]);
            printf("\n");
        }
    }
    else if (max(n,m)>=4&&max(n,m)%2==1)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        cnt=-1;
        rp(i,0,min(n,m)-1)
            rp(j,0,max(n,m)-1)
                lin[++cnt]=f[i][j];
        int x=min(n,m)-1,y=max(n,m)/2;
        memset(f,0,sizeof(f));
        rp(i,0,cnt)
        {
            f[x][y]=lin[i];
            int xx=(x-1+min(n,m))%min(n,m),yy=(y-1+max(n,m))%max(n,m);
            if (f[xx][yy])
                xx=(x+1)%min(n,m),yy=y;
            x=xx,y=yy;
        }
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[i][j]:f[j][i]);
            printf("\n");
        }
    }
    else printf("NO\n");
    return 0;
}


#include<cstdio>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[N][SQN],lin[N],n,m;
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    if (n==1&&m==1)
        printf("YES\n1\n");
    else if (max(n,m)>=4)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,min(n,m)-1)
            rp(j,0,max(n,m)-1)
                f[i][j]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i);
        if (m==max(n,m))
            rp(i,0,(m==max(n,m)?n-1:m-1))
            {
                rp(j,0,(m==max(n,m)?m-1:n-1))
                    printf("%d ",f[i][j]);
                printf("\n");
            }
    }
    else printf("NO\n");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[SQN][N],lin[N],n,m,pt[N];
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    else if (n==1&&m==1)
        printf("YES\n1\n");
    else if (max(n,m)>=4&&(min(n,m)>=4||max(n,m)%2==0||min(n,m)==1))
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,min(n,m))
            pt[i]=i;
        change(pt,min(n,m),0);
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i%2);
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[pt[i]][j]:f[pt[j]][i]);
            printf("\n");
        }
    }
    else if (max(n,m)>=4&&max(n,m)%2==1)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        cnt=-1;
        rp(i,0,max(n,m)-1)
            rp(j,0,min(n,m)-1)
                lin[++cnt]=f[j][i];
        int x=min(n,m)-1,y=max(n,m)/2;
        memset(f,0,sizeof(f));
        rp(i,0,cnt)
        {
            f[x][y]=lin[i];
            int xx=(x-1+min(n,m))%min(n,m),yy=(y-1+max(n,m))%max(n,m);
            if (f[xx][yy])
                xx=(x+1)%min(n,m),yy=y;
            x=xx,y=yy;
        }
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[i][j]:f[j][i]);
            printf("\n");
        }
    }
    else printf("NO\n");
    return 0;
}


#include<cstdio>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[SQN][N],lin[N],n,m;
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    else if (n==1&&m==1)
        printf("YES\n1\n");
    else if (max(n,m)>=4)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,n-1)
            rp(j,0,m-1)
            if (m==max(n,m)) f[i][j]=++cnt;
            else f[j][i]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i);
        rp(i,0,n-1)
        {
            rp(j,0,m-1)
                printf("%d ",m==max(n,m)?f[i][j]:f[j][i]);
            printf("\n");
        }
    }
    else printf("NO\n");
    return 0;
}


#include<cstdio>
#include<algorithm>
#define rp(i,x,y) for (int i=x;i<=y;i++)
const int N=1e5+10,SQN=320;
using namespace std;
int f[N][SQN],lin[N],n,m;
void change(int f[],int len,int flg)
{
    if (len==4)
        swap(f[0],f[2]),swap(f[1],f[2]),swap(f[3],f[2]);
    else if (len>4)
    {
        rp(i,0,(len-1)/2)
            lin[i]=f[i*2],lin[i+(len-1)/2+1]=f[i*2+1];
        rp(i,0,len-1)
            f[i]=lin[i];
    }
    if (flg)
        rp(i,0,(len-1)/2)
            swap(f[i],f[len-i-1]);
}

int main(void)
{
    scanf("%d%d",&n,&m);
    if (n==3&&m==3)
        printf("YES\n6 2 7\n1 9 5\n8 4 3\n");
    else if (max(n,m)>=4)
    {
        printf("YES\n");
        int cnt=0;
        rp(i,0,min(n,m)-1)
            rp(j,0,max(n,m)-1)
                f[i][j]=++cnt;
        rp(i,0,min(n,m)-1)
            change(f[i],max(n,m),i);
        if (m==max(n,m))
            rp(i,0,(m==max(n,m)?n-1:m-1))
            {
                rp(j,0,(m==max(n,m)?m-1:n-1))
                    printf("%d ",f[i][j]);
                printf("\n");
            }
    }
    else printf("NO\n");
}