#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
#include<time.h>
#include<string.h>
using namespace std;
#define LL __int64
#define N 1000005
int a[N],num[N];

int main()
{
    int i,n,k;
    int l,r,cnt,pos;
    while(~scanf("%d%d",&n,&k)){
        for(i=1;i<=n;++i){
            scanf("%d",&a[i]);
        }
        l=r=1;
        cnt=1;
        pos=2;
        memset(num,0,sizeof(num));
        num[a[1]]=1;
        for(i=1;i<=n;++i){
            while(pos<=n&&cnt<=k){
                ++num[a[pos]];
                if(num[a[pos]]==1){
                    ++cnt;
                }
                if(cnt<=k)
                    ++pos;
            }
            if(r-l<pos-1-i){
                r=pos-1;
                l=i;
            }
            --num[a[i]];
            if(num[a[i]]==0){
                --cnt;
                ++pos;
            }
        }
        printf("%d %d\n",l,r);
    }
    return 0;
}


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

int vis[1000010] = {0};
bool viss[1000010] = {0};
struct node
{
    int l, r, len;
} a[101010];

bool cmp(node xx, node yy)
{
    return xx.len > yy.len;
}

int main()
{
    queue<int> q;
    int dif = 0;
    int l = 1, tmp, cnt = 0, num = 0;
    int n, k, x;
    cnt = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(!viss[x])
        {
            viss[x] = true;
            dif ++;
        }
        if(!vis[x])
        {
            if(cnt == k)
            {
                tmp = q.front();
               // cout << vis[tmp] << endl;
                while(q.size() && vis[tmp] >= 1)
                {
                    if(vis[tmp] == 1 && q.front() == tmp)
                    {
                        break;
                    }
                    vis[q.front()] --;
                    if(vis[q.front()] == 0)
                    {
                        cnt --;
                    }
                    q.pop();
                    l++;
                }
                vis[x] ++;
                cnt ++;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r-a[num].l+1;
                }
            }
            else
            {
                cnt ++;
                vis[x] ++;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r - a[num].l + 1;
                }
            }
        }
        else if(vis[x])
        {
            q.push(x);
            vis[x] ++;
            if(cnt == k)
            {
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
        }
    }
    if(dif <= k)
    {
        printf("%d %d\n", 1, n);
        return 0;
    }
    sort(a+1,a+num+1, cmp);
    printf("%d %d\n", a[1].l, a[1].r);
    return 0;
}

//10
//3
//1 1 2 2 2 3 4 5 5 5

//9 3
//5 6 1 2 5 5 1 6 5


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
int num[500008];
int vis[5000008];
int n,k;
int main(){
    memset(vis,0,sizeof(vis));
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
    }
    int c=0;
    int l=1,r=1;
    for(int i=1;i<=n;i++){
        if(!vis[num[i]]) c++;
        vis[num[i]]++;
        if(c==k){
            while(vis[num[i+1]]){
                i++;
                vis[num[i]]++;
            }
            r=i;break;
        }
    }
    if(c<k){
        printf("1 %d\n",n);
        return 0;
    }
    int tl=l,tr=r;
    while(l<n-k+1){
        vis[num[l]]--;
        if(!vis[num[l]]) c--;
        l++;
        for(;r<=n;){
            r++;
            vis[num[r]]++;
            if(vis[num[r]] == 1) c++;
            if(c == k){
                while(vis[num[r+1]]){
                    r++;
                    vis[num[r]]++;
                }
                if(r-l > tr-tl){
                    tl=l;
                    tr=r;
                }
                break;
            }
        }
    }
    printf("%d %d\n",tl,tr);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
int num[500008];
int vis[5000008];
int n,k;
int main(){
    memset(vis,0,sizeof(vis));
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
    }
    int c=0;
    int l=1,r=1;
    for(int i=1;i<=n;i++){
        if(!vis[num[i]]) c++;
        vis[num[i]]++;
        if(c==k){
            while(vis[num[i+1]]){
                i++;
                vis[num[i]]++;
            }
            r=i;break;
        }
    }
    if(c<7){
        printf("1 %d\n",n);
        return 0;
    }
    int tl=l,tr=r;
    while(l<n-k+1){
        vis[num[l]]--;
        if(!vis[num[l]]) c--;
        l++;
        for(;r<=n;){
            r++;
            vis[num[r]]++;
            if(vis[num[r]] == 1) c++;
            if(c == k){
                while(vis[num[r+1]]){
                    r++;
                    vis[num[r]]++;
                }
                if(r-l > tr-tl){
                    tl=l;
                    tr=r;
                }
                break;
            }
        }
    }
    printf("%d %d\n",tl,tr);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
int num[500008];
int vis[5000008];
int n,k;
int main(){
    memset(vis,0,sizeof(vis));
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
    }
    int c=0;
    int l=1,r=1;
    for(int i=1;i<n;i++){
        if(!vis[num[i]]) c++;
        vis[num[i]]++;
        if(c==k){
            while(i<n && vis[num[i+1]]){
                i++;
                vis[num[i]]++;
            }
            r=i;break;
        }
    }
    if(c<k){
        printf("1 %d\n",n);
        return 0;
    }
    int tl=l,tr=r;
    while(l<n-k+1){
        while(true){
            vis[num[l]]--;
            l++;
            if(!vis[num[l-1]]){
                c--;
                break;
            }
        }
        for(;r<n;){
            r++;
            vis[num[r]]++;
            if(vis[num[r]] == 1) c++;
            if(c == k){
                while(r<n && vis[num[r+1]]){
                    r++;
                    vis[num[r]]++;
                }
                if(r-l > tr-tl){
                    tl=l;
                    tr=r;
                }
                break;
            }
        }
    }
    printf("%d %d\n",tl,tr);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
int num[500008];
int vis[5000008];
int n,k;
int main(){
    memset(vis,0,sizeof(vis));
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
    }
    int c=0;
    int l=1,r=1;
    for(int i=1;i<=n;i++){
        if(!vis[num[i]]) c++;
        vis[num[i]]++;
        if(c==k){
            while(vis[num[i+1]]){
                i++;
                vis[num[i]]++;
            }
            r=i;break;
        }
    }
    if(c<k){
        printf("1 %d\n",n);
        return 0;
    }
    int tl=l,tr=r;
    while(l<n-k+1){
        while(true){
            vis[num[l]]--;
            l++;
            if(!vis[num[l-1]]){
                c--;
                break;
            }
        }
        for(;r<n;){
            r++;
            vis[num[r]]++;
            if(vis[num[r]] == 1) c++;
            if(c == k){
                while(vis[num[r+1]] && r<n){
                    r++;
                    vis[num[r]]++;
                }
                if(r-l > tr-tl){
                    tl=l;
                    tr=r;
                }
                break;
            }
        }
    }
    printf("%d %d\n",tl,tr);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
int num[500008];
int vis[5000008];
int n,k;
int main(){
    memset(vis,0,sizeof(vis));
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&num[i]);
    }
    int c=0;
    int l=1,r=1;
    for(int i=1;i<=n;i++){
        if(!vis[num[i]]) c++;
        vis[num[i]]++;
        if(c==k){
            while(vis[num[i+1]]){
                i++;
                vis[num[i]]++;
            }
            r=i;break;
        }
    }
    int tl=l,tr=r;
    while(l<n-k+1){
        vis[num[l]]--;
        if(!vis[num[l]]) c--;
        l++;
        for(;r<=n;){
            r++;
            vis[num[r]]++;
            if(vis[num[r]] == 1) c++;
            if(c == k){
                while(vis[num[r+1]]){
                    r++;
                    vis[num[r]]++;
                }
                if(r-l > tr-tl){
                    tl=l;
                    tr=r;
                }
                break;
            }
        }
    }
    printf("%d %d\n",tl,tr);
    return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define len(n) n.length()
#define mp make_pair
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;i++)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("0.in","r",stdin),freopen("0.out","w",stdout)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define vll vector<long long int>
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define g2(m,n) cin >> m >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define onn printf("\n")
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define alll(n,i,j) n.begin()+i,n.begin()+j
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m) memset(n,m,sizeof(n))
#define bitc(n) __builtin_popcount(n)
#define mod 1000000007
#define ma(m,n) m = max(m,n)
#define mi(m,n) m = min(m,n)
#define EPSILON 1e-9
#define PI 3.14159265358979323846

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;
#define N 100005

                                                                                inline ll mod_pow(ll a,ll n,ll b){ll res = 1;while(n){if(n&1) {res = (res*a)%b;}a = (a*a)%b;n >>= 1;}return res%b;}
                                                                                inline ll mod_div(ll a,ll b,ll md){ll ans = (a*mod_pow(b,md-2,md))%md; return ans;}
                                                                                inline void add(ll &a,ll b,ll md){a += b; if(a >= md) a -= md;}
                                                                                inline void sub(ll &a,ll b,ll md){add(a,md-b,md);}
                                                                                inline ll mul(ll a,ll b,ll md){ return (ll)(a*b)%md;}
/*bool prime[N];
//vll pr;
//ll factor[N];
void seive(){
prime[0] = prime[1] =1;
//forp(i,1,N) factor[i] = i;
for(ll i = 4;i<N;i += 2) {
    //factor[i] = 2;
    prime[i]= 1;
}
for(ll i = 3;i*i<N; i += 2){
    if(!prime[i]){
        for(ll j=i*i;j<N;j += i){
            prime[j]= 1;
            //factor[j] = i;
        }
    }
 }
 forp(i,2,N) if(!prime[i]) pr.pb(i);
}
*/

/*
void upd(ll idx,int bit){
    while(idx <= n){
        ++BIT[idx][bit];
        idx += idx&-idx;
    }
}

ll query(ll idx,int bit){
    ll sum = 0;
    while(idx > 0){
        sum += BIT[idx][bit];
        idx -= idx&-idx;
    }
 return sum;
}
*/

int a[5*N],cnt[N*10];

int main(){
    boost;
    int n,k;
    cin >> n >> k;
    forp(i,1,n){
        cin >> a[i];
    }

    int now = 0;
    int left = 1,right = 0;
    int mn = 1,mx = 1;

    forp(i,1,n){
        ++right;
        ++cnt[a[i]];
        if(cnt[a[i]] == 1){
            ++now;
            if(now > k){
                while(cnt[a[left]] > 1){
                    --cnt[a[left]];
                    ++left;
                }
                --cnt[a[left]];
                ++left;
                --now;
            }
        }
      if(mx - mn < right - left){
        mx = right;
        mn = left;
      }
    }

    cout << mn << " " << mx;
    return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define len(n) n.length()
#define mp make_pair
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;i++)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("0.in","r",stdin),freopen("0.out","w",stdout)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define vll vector<long long int>
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define g2(m,n) cin >> m >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define onn printf("\n")
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define alll(n,i,j) n.begin()+i,n.begin()+j
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m) memset(n,m,sizeof(n))
#define bitc(n) __builtin_popcount(n)
#define mod 1000000007
#define ma(m,n) m = max(m,n)
#define mi(m,n) m = min(m,n)
#define EPSILON 1e-9
#define PI 3.14159265358979323846

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;
#define N 100005

                                                                                inline ll mod_pow(ll a,ll n,ll b){ll res = 1;while(n){if(n&1) {res = (res*a)%b;}a = (a*a)%b;n >>= 1;}return res%b;}
                                                                                inline ll mod_div(ll a,ll b,ll md){ll ans = (a*mod_pow(b,md-2,md))%md; return ans;}
                                                                                inline void add(ll &a,ll b,ll md){a += b; if(a >= md) a -= md;}
                                                                                inline void sub(ll &a,ll b,ll md){add(a,md-b,md);}
                                                                                inline ll mul(ll a,ll b,ll md){ return (ll)(a*b)%md;}
/*bool prime[N];
//vll pr;
//ll factor[N];
void seive(){
prime[0] = prime[1] =1;
//forp(i,1,N) factor[i] = i;
for(ll i = 4;i<N;i += 2) {
    //factor[i] = 2;
    prime[i]= 1;
}
for(ll i = 3;i*i<N; i += 2){
    if(!prime[i]){
        for(ll j=i*i;j<N;j += i){
            prime[j]= 1;
            //factor[j] = i;
        }
    }
 }
 forp(i,2,N) if(!prime[i]) pr.pb(i);
}
*/

/*
void upd(ll idx,int bit){
    while(idx <= n){
        ++BIT[idx][bit];
        idx += idx&-idx;
    }
}

ll query(ll idx,int bit){
    ll sum = 0;
    while(idx > 0){
        sum += BIT[idx][bit];
        idx -= idx&-idx;
    }
 return sum;
}
*/

int a[5*N],cnt[N*10];

int main(){
    int n,k;
    cin >> n >> k;
    forp(i,1,n){
        cin >> a[i];
    }

    int now = 0;
    int left = 1,right = 0;
    int mn = 1,mx = 1;

    forp(i,1,n){
        ++right;
        ++now;
        ++cnt[a[i]];
        if(cnt[a[i]] == 1){
            if(now > k){
                while(cnt[a[left]] > 1){
                    --cnt[a[left]];
                    ++left;
                    --now;
                }
                --cnt[a[left]];
                ++left;
                --now;
            }
        }
      if(mx - mn < right - left){
        mx = right;
        mn = left;
      }
    }

    cout << mn << " " << mx;
    return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define len(n) n.length()
#define mp make_pair
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;i++)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("0.in","r",stdin),freopen("0.out","w",stdout)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define vll vector<long long int>
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define g2(m,n) cin >> m >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define onn printf("\n")
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define alll(n,i,j) n.begin()+i,n.begin()+j
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m) memset(n,m,sizeof(n))
#define bitc(n) __builtin_popcount(n)
#define mod 1000000007
#define ma(m,n) m = max(m,n)
#define mi(m,n) m = min(m,n)
#define EPSILON 1e-9
#define PI 3.14159265358979323846

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;
#define N 100005

                                                                                inline ll mod_pow(ll a,ll n,ll b){ll res = 1;while(n){if(n&1) {res = (res*a)%b;}a = (a*a)%b;n >>= 1;}return res%b;}
                                                                                inline ll mod_div(ll a,ll b,ll md){ll ans = (a*mod_pow(b,md-2,md))%md; return ans;}
                                                                                inline void add(ll &a,ll b,ll md){a += b; if(a >= md) a -= md;}
                                                                                inline void sub(ll &a,ll b,ll md){add(a,md-b,md);}
                                                                                inline ll mul(ll a,ll b,ll md){ return (ll)(a*b)%md;}
/*bool prime[N];
//vll pr;
//ll factor[N];
void seive(){
prime[0] = prime[1] =1;
//forp(i,1,N) factor[i] = i;
for(ll i = 4;i<N;i += 2) {
    //factor[i] = 2;
    prime[i]= 1;
}
for(ll i = 3;i*i<N; i += 2){
    if(!prime[i]){
        for(ll j=i*i;j<N;j += i){
            prime[j]= 1;
            //factor[j] = i;
        }
    }
 }
 forp(i,2,N) if(!prime[i]) pr.pb(i);
}
*/

/*
void upd(ll idx,int bit){
    while(idx <= n){
        ++BIT[idx][bit];
        idx += idx&-idx;
    }
}

ll query(ll idx,int bit){
    ll sum = 0;
    while(idx > 0){
        sum += BIT[idx][bit];
        idx -= idx&-idx;
    }
 return sum;
}
*/

int a[5*N],cnt[N*10];

int main(){
    boost;
    int n,k;
    cin >> n >> k;
    forp(i,1,n){
        cin >> a[i];
    }

    int now = 0;
    int left = 1,right = 0;
    int mn = 1,mx = 1;

    forp(i,1,n){
        ++right;
        ++now;
        if(cnt[a[i]] == 0){
            ++cnt[a[i]];
            if(now > k){
                --now;
                while(cnt[a[left]] > 1){
                    --cnt[a[left]];
                    ++left;
                }
                --cnt[a[left]];
                ++left;
            }
        }
      if(mx - mn < right - left){
        mx = right;
        mn = left;
      }
    }

    cout << mn << " " << mx;
    return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define len(n) n.length()
#define mp make_pair
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;i++)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("0.in","r",stdin),freopen("0.out","w",stdout)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define vll vector<long long int>
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define g2(m,n) cin >> m >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define onn printf("\n")
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define alll(n,i,j) n.begin()+i,n.begin()+j
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m) memset(n,m,sizeof(n))
#define bitc(n) __builtin_popcount(n)
#define mod 1000000007
#define ma(m,n) m = max(m,n)
#define mi(m,n) m = min(m,n)
#define EPSILON 1e-9
#define PI 3.14159265358979323846

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;
#define N 100005

                                                                                inline ll mod_pow(ll a,ll n,ll b){ll res = 1;while(n){if(n&1) {res = (res*a)%b;}a = (a*a)%b;n >>= 1;}return res%b;}
                                                                                inline ll mod_div(ll a,ll b,ll md){ll ans = (a*mod_pow(b,md-2,md))%md; return ans;}
                                                                                inline void add(ll &a,ll b,ll md){a += b; if(a >= md) a -= md;}
                                                                                inline void sub(ll &a,ll b,ll md){add(a,md-b,md);}
                                                                                inline ll mul(ll a,ll b,ll md){ return (ll)(a*b)%md;}
/*bool prime[N];
//vll pr;
//ll factor[N];
void seive(){
prime[0] = prime[1] =1;
//forp(i,1,N) factor[i] = i;
for(ll i = 4;i<N;i += 2) {
    //factor[i] = 2;
    prime[i]= 1;
}
for(ll i = 3;i*i<N; i += 2){
    if(!prime[i]){
        for(ll j=i*i;j<N;j += i){
            prime[j]= 1;
            //factor[j] = i;
        }
    }
 }
 forp(i,2,N) if(!prime[i]) pr.pb(i);
}
*/

/*
void upd(ll idx,int bit){
    while(idx <= n){
        ++BIT[idx][bit];
        idx += idx&-idx;
    }
}

ll query(ll idx,int bit){
    ll sum = 0;
    while(idx > 0){
        sum += BIT[idx][bit];
        idx -= idx&-idx;
    }
 return sum;
}
*/

int a[5*N],cnt[N*10];

int main(){
    int n,k;
    cin >> n >> k;
    forp(i,1,n){
        cin >> a[i];
    }

    int now = 0;
    int left = 1,right = 0;
    int mn = 1,mx = 1;

    forp(i,1,n){
        ++right;
        ++cnt[a[i]];
        if(cnt[a[i]] == 1){
            ++now;
            if(now > k){
                while(cnt[a[left]] > 1){
                    --cnt[a[left]];
                    ++left;
                }
                --cnt[a[left]];
                ++left;
                --now;
            }
        }
      if(mx - mn < right - left){
        mx = right;
        mn = left;
      }
    }

    cout << mn << " " << mx;
    return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define len(n) n.length()
#define mp make_pair
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;i++)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define fre     freopen("0.in","r",stdin),freopen("0.out","w",stdout)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define vll vector<long long int>
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define g2(m,n) cin >> m >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define onn printf("\n")
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define alll(n,i,j) n.begin()+i,n.begin()+j
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m) memset(n,m,sizeof(n))
#define bitc(n) __builtin_popcount(n)
#define mod 1000000007
#define ma(m,n) m = max(m,n)
#define mi(m,n) m = min(m,n)
#define EPSILON 1e-9
#define PI 3.14159265358979323846

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;
#define N 100005

                                                                                inline ll mod_pow(ll a,ll n,ll b){ll res = 1;while(n){if(n&1) {res = (res*a)%b;}a = (a*a)%b;n >>= 1;}return res%b;}
                                                                                inline ll mod_div(ll a,ll b,ll md){ll ans = (a*mod_pow(b,md-2,md))%md; return ans;}
                                                                                inline void add(ll &a,ll b,ll md){a += b; if(a >= md) a -= md;}
                                                                                inline void sub(ll &a,ll b,ll md){add(a,md-b,md);}
                                                                                inline ll mul(ll a,ll b,ll md){ return (ll)(a*b)%md;}
/*bool prime[N];
//vll pr;
//ll factor[N];
void seive(){
prime[0] = prime[1] =1;
//forp(i,1,N) factor[i] = i;
for(ll i = 4;i<N;i += 2) {
    //factor[i] = 2;
    prime[i]= 1;
}
for(ll i = 3;i*i<N; i += 2){
    if(!prime[i]){
        for(ll j=i*i;j<N;j += i){
            prime[j]= 1;
            //factor[j] = i;
        }
    }
 }
 forp(i,2,N) if(!prime[i]) pr.pb(i);
}
*/

/*
void upd(ll idx,int bit){
    while(idx <= n){
        ++BIT[idx][bit];
        idx += idx&-idx;
    }
}

ll query(ll idx,int bit){
    ll sum = 0;
    while(idx > 0){
        sum += BIT[idx][bit];
        idx -= idx&-idx;
    }
 return sum;
}
*/

int a[5*N],cnt[N*10];

int main(){
    int n,k;
    cin >> n >> k;
    forp(i,1,n){
        cin >> a[i];
    }

    int now = 0;
    int left = 1,right = 0;
    int mn = 1,mx = 1;

    forp(i,1,n){
        ++right;
        ++cnt[a[i]];
        if(cnt[a[i]] == 1){
            ++now;
            if(now > k){
                while(cnt[a[left]] > 1){
                    --cnt[a[left]];
                    ++left;
                    --now;
                }
                --cnt[a[left]];
                ++left;
                --now;
            }
        }
      if(mx - mn < right - left){
        mx = right;
        mn = left;
      }
    }

    cout << mn << " " << mx;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define MAX 500100

int n, k, contador;
int arr[MAX], mark[2*MAX];
int main() {
        scanf("%d %d", &n, &k);
        memset(mark, 0, sizeof mark);
        contador = 0;
        for (int i = 1; i <= n; i++) {
            scanf("%d",&arr[i]);
            if (i <= k) {
                if (!mark[arr[i]]) {
                    contador++;
                    mark[arr[i]] = 1;
                } else mark[arr[i]]++;
            }
        }
        int l = 1;
        int r = k;
        int ladol = 1, lador=k;
        while(r < n) {
            if (mark[arr[r+1]] || contador < k) {
                r++;
                if (mark[arr[r]] == 0) contador++;
                mark[arr[r]]++;
                if(lador-ladol < r - l) ladol = l, lador = r;
            } else {
                if (mark[arr[l]] == 1) contador--;
                mark[arr[l]]--;
                l++;
            }
        }
        printf("%d %d\n", ladol, lador);
    return 0;
}
// 1457830750788


#include <stdio.h>
#include <map>
#include <algorithm>

using namespace std;
int n,k, vet[500100], l=0, r=0, bestl=0, bestr=0, diff=0;
map<int, int> mii;

int main(){
	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++) scanf("%d", &vet[i]);

	while(r < n){
		while(diff>k){
			if(mii[vet[l]]==1) diff--;
			mii[vet[l]]--;
			l++;
		}

		if(mii[vet[r]]==0) diff++;
		mii[vet[r]]++;

		if(diff <= k && abs(r-l) > abs(bestr-bestl)) { bestl = l; bestr = r;}

		r++;
	}

	printf("%d %d\n", bestl+1, bestr+1);
	return 0;
}
// 1474653364737


#include <bits/stdc++.h>

using namespace std;

vector<int> seq;
set<int> diff;

int main(){
	int n, k;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int start = 0, fim = 0, startF = 0, fimF = 0;
	diff.insert(num[0]);

	for( int i = 1; i < n; i++ ){
		diff.insert(num[i]);
		if ( diff.size() > k ){
			if ( ( fim - start ) > ( fimF - startF ) ){
				fimF = fim;
				startF = start;
			}
			diff.erase(num[start]);
			start++;
		}
		fim++;
	}

	if ( ( fim - start ) > ( fimF - startF ) ){
		fimF = fim;
		startF = start;
	}

	printf("%d %d\n", startF+1, fimF+1);

	return 0;
}
// 1456683183425


#include <stdio.h>
#include <vector>
#include <map>
using namespace std;

int a[512345];

int main(void)
{
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	int r = 1;
	int sz = -1;
	int l;
	map<int,int> rdm;
	for(int i = 1; i <= n; i++)
	{
		while(r <= n && (rdm.find(a[r]) != rdm.end() || rdm.size() < k))
			rdm[a[r++]]++;

		if(r-i > sz)
			l = i, sz = r-i;

		rdm[a[i]]--;
		if(rdm[a[i]] == 0)
			rdm.erase(a[i]);
	}
	printf("%d %d\n", l, l+sz - 1);

}

// 1474654536881


int main(){
	long long n, k;
	scanf("%lld %lld", &n, &k);
	long long a[n];
	int i;
	for(i = 0; i < n; i++) scanf("%lld", &a[i]);
	if(k == 1) printf("%d %d\n", 1, 1);
	else{
		long long l = 0, c = 1, lmax = 0, max = 1;
		for(i = 0; i < n; i++){
			if(abs(a[i] - a[i+1]) == 1){
				c++;
			}else{
				if(c <= max){
					l = i+1;
					c = 1;
				}else{
					lmax = l;
					l = i+1;
					max = c;
					c = 1;
				}
			}
		}
		printf("%lld %lld\n", lmax+1, lmax+max);
	}
	return 0;
}
// 1456585028699


#include <bits/stdc++.h>

using namespace std;

int main(){
	int n, k;
	vector<int> seq;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int startFinal = 1, countFinal = 0;
	int start = 1;
	int count = 0;
	bool negative = false;
	int diff = 1;
	bool cheio = false;

	for( int i = 1; i < n && !cheio; i++ ){
		int d = abs(num[i] - num[i-1]);
		if ( d == 1 ){
			count++;
			bool repetido = false;
			if ( seq.empty() ){
				seq.push_back(num[i-1]);
			}
			int s = seq.size();
			for( int j = 0; j < s && !repetido; j++ ){
				if ( seq[j] == num[i] ){
					repetido = true;
				}
			}
			if ( !repetido ){
				seq.push_back(num[i]);
				diff++;
				if ( diff > k ){
					cheio = true;
				}
			}
		} else {
			if ( count > countFinal ){
				startFinal = start;
				countFinal = count;
			}
			start = i+1;
			count = 0;
			seq.clear();
			diff = 1;
		}
	}
	printf("%d %d\n", startFinal, (startFinal+countFinal));
	return 0;
}
// 1456583521640


#include <bits/stdc++.h>

using namespace std;

int main(){
	int n, k;
	vector<int> seq;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int startFinal = 1, countFinal = 0;
	int start = 1;
	int count = 0;
	bool negative = false;
	int diff = 1;
	bool cheio = false;

	for( int i = 1; i < n && !cheio; i++ ){
		int d = abs(num[i] - num[i-1]);
		if ( d == 1 ){
			count++;
			bool repetido = false;
			if ( seq.empty() ){
				seq.push_back(num[i-1]);
			}
			int s = seq.size();
			for( int j = 0; j < s && !repetido; j++ ){
				if ( seq[j] == num[i] ){
					repetido = true;
				}
			}
			if ( !repetido ){
				seq.push_back(num[i]);
				diff++;
				if ( diff > k ){
					cheio = true;
					count--;
				}
			}
		} else {
			//cout << "Entrou " << num[i] << endl;
			if ( count > countFinal ){
				startFinal = start;
				countFinal = count;
			}
			start = i+1;
			count = 0;
			seq.clear();
			diff = 1;
		}
	}

	if ( countFinal == 0 ){
		countFinal = count;
		startFinal = start;
	}
	printf("%d %d\n", startFinal, (startFinal+countFinal));

	return 0;
}
// 1456584151763


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000010];

set <int> se;

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}

	ll maxI = 0;
	ll maxJ = 0;
	ll diffNumbers = 0;

	for(ll i=0; i<n; i++) {
		diffNumbers = 1;
		se.clear();
		se.insert(arr[i]);
		for(ll j=i+1; j<n; j++) {
			if(!se.count(arr[j])) {
				diffNumbers++;
				se.insert(arr[j]);
				if(diffNumbers > k) {
					break;
				} else {
					if(abs(i - j) > abs(maxI - maxJ)) {
						maxI = i;
						maxJ = j;
					}
				}
			} else {
				if(abs(i - j) > abs(maxI - maxJ)) {
					maxI = i;
					maxJ = j;
				}
			}
		}
	}

	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456873881436


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  frl(i, a, b) for(long long int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000010], cnt[1000010];

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}

	ll maxI = 0;
	ll maxJ = 0;
	ll diffNumbers = 0;
	ll j = 1;
	ll i = 0;
	int overK;
	cnt[arr[i]]++;
	diffNumbers++;
	while(j < n) {
		overK = 0;
		if(!cnt[arr[j]]) {
			if(diffNumbers+1 > k) {
				overK = 1;
				//printf("entrou i: %lld j: %lld diffNumbers: %lld currCNT[I]: %lld\n", i, j, diffNumbers+1, cnt[arr[i]]);
				if(cnt[arr[i]] > 1) {
					cnt[arr[i]]--;
				} else {
					cnt[arr[i]]--;
					diffNumbers--;
				}
			} else {
				diffNumbers++;
				cnt[arr[j]]++;
				if(abs(i-j) > abs(maxI-maxJ)) {
					maxI = i;
					maxJ = j;
				}
			}
		} else {
			cnt[arr[j]]++;
			if(abs(i-j) > abs(maxI-maxJ)) {
				maxI = i;
				maxJ = j;
			}
		}
		if(overK) {
			i++;
			printf("entrou i: %lld j: %lld diffNumbers: %lld currCNT[I]: %lld\n", i, j, diffNumbers+1, cnt[arr[i]]);
		} else {
			j++;
		}
	}

	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456923587678


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000010];

ll checkArr(ll i, ll j, ll v) {
	for(ll q=i; q<j; q++) {
		if(arr[q] == v) {
			return 1;
		}
	}
	return 0;
}

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}

	ll maxI = 0;
	ll maxJ = 0;
	ll diffNumbers = 0;

	if(k != 1) {
		for(ll i=0; i<n; i++) {
			diffNumbers = 1;
			for(ll j=i+1; j<n; j++) {
				if(!checkArr(i, j, arr[j])) {
					diffNumbers++;
					if(diffNumbers > k) {
						break;
					} else {
						if(abs(i - j) > abs(maxI - maxJ)) {
							maxI = i;
							maxJ = j;
						}
					}
				} else {
					if(abs(i - j) > abs(maxI - maxJ)) {
						maxI = i;
						maxJ = j;
					}
				}
			}
		}
	}

	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456859266787


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    vector<int>vec;
    rep(i,x){
    cin>>f;vec.pb(f);}
    set<int>stt;
    map<int,int>mop;
    int mx=0,I=0,J=0,n=0;
    rep(i,x)
    {
        if(!mop[vec[i]])
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
        mop[vec[i]]++;
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k;
    cin>>x>>k;
    vector<int>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<int>stt;
    int mx=0,val=0,c=0,st=0,en=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
         if(!c)
            val=vec[n];
        stt.insert(vec[i]),c++;
        if(stt.size()>k)
        {
            if(abs(n-i)>abs(I-J))
                I=n,J=i;
            stt.erase(val),n++,c=0;
        }
        else
            I=n,J=i;
    }
    if(abs(n-i)>abs(I-J))
        I=n,J=i;
    cout<<I+1<<" "<<J<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int vec[500500];
set<int>stt;
map<int,int>mop;
int x,k;
int main()
{
    done
    cin>>x>>k;
    rep(i,x){
    cin>>vec[i];}
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int vec[500500];
set<int>stt;
map<int,int>mop;
int x,k;
int main()
{
    done
    cin>>x>>k;
    rep(i,x){
    cin>>vec[i];}
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        if(!mop[vec[i]])
           stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){
            mop[vec[n]]--;
            if(!mop[vec[n]])
                stt.erase(vec[n]);
            n++;
            }
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
        mop[vec[i]]++;
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
set<int>stt;
map<int,int>mop;
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    vector<int>vec;
    rep(i,x){
    cin>>f;vec.pb(f);}
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
map<int,int>mop;
int main()
{
    done
    int x,k,f;
    scanf("%d%d",&x,&k);
    vector<int>vec(x);
    rep(i,x)
    scanf("%d",&vec[i]);
    int st=0,en=0,mx=0,j=0,ans=0;
    rep(i,x)
    {
        mop[vec[i]]++;
        if(mop[vec[i]]==1)mx++;
        while(mx>k)
        {
            mop[vec[j]]--;
            if(!mop[vec[j]])mx--;
            j++;
        }
        if(ans<abs(i-j+1))
            ans=abs(j-i+1),st=j,en=i;
    }
    printf("%d %d\n",st+1,en+1);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
map<int,int>mop;
int main()
{
    done
    int x,k,f;
    scanf("%d%d",&x,&k);
    vector<int>vec(x);
    rep(i,x)
    scanf("%d",&vec[i]);
    int st=0,en=0,mx=0,j=0,ans=0;
    rep(i,x)
    {
        mop[vec[i]]++;
        if(mop[vec[i]]==1)mx++;
        while(mx>k)
        {
            mop[vec[j]]--;
            if(!mop[vec[j]])mx--;
            j++;
        }
        if(ans<=i-j)
            ans=i-j,st=j,en=i;
    }
    printf("%d %d\n",st+1,en+1);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    vector<int>vec;
    rep(i,x){
    cin>>f;vec.pb(f);}
    set<int>stt;
    map<int,int>mop;
    int mx=0,I=0,J=0,n=0;
    rep(i,x)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k;
    cin>>x>>k;
    vector<int>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<int>stt;
    int mx=0,val=0,c=0,st=0,en=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
         if(!c)
            val=vec[n];
        stt.insert(vec[i]),c++;
        if(stt.size()>k)
        {
            if(abs(n-i)>abs(I-J))
                I=n,J=i-1;
            stt.erase(val),n++,c=0;
       // cout<<I<<" "<<J<<" "<<stt.size()<<" "<<val<<endl;
        }
    }
  //  if(abs(n-i)>abs(I-J))
    //    I=n,J=i-1;
    if(!I&&!J)
        cout<<1<<" "<<x<<endl;
    else
    cout<<I<<" "<<J<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
vector<int>vec;
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    rep(i,x){
    cin>>f;vec.pb(f);}
    set<int>stt;
    map<int,int>mop;
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
set<int>stt;
map<int,int>mop;
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    vector<int>vec;
    rep(i,x){
    cin>>f;vec.pb(f);}
    int mx=0,I=0,J=0,n=0;
    for(int i=0;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){
                    mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
set<int>stt;
map<int,int>mop;
vector<int>vec;
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    rep(i,x){
    cin>>f;vec.pb(f);}
    int mx=0,I=0,J=0,n=0;
    for(int i=0;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){
                    mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k;
    cin>>x>>k;
    vector<int>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<int>stt;
    map<int,int>mop;
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k;
    cin>>x>>k;
    vector<int>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<int>stt;
    int mx=0,val=0,c=0,st=0,en=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
         if(!c)
            val=vec[n];
        stt.insert(vec[i]),c++;
        if(stt.size()>k)
        {
            if(abs(n-i)>abs(I-J))
                I=n,J=i;
            stt.erase(val),n++,c=0;
       // cout<<I<<" "<<J<<" "<<stt.size()<<" "<<val<<endl;
        }
    }
    if(abs(n-i)>abs(I-J))
        I=n,J=i;
    cout<<I+1<<" "<<J<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    ll x,k;
    cin>>x>>k;
    vector<ll>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<ll>stt;
    ll val=0,c=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
         if(!c)
            val=vec[n];
        stt.insert(vec[i]),c++;
        if(stt.size()>k)
        {
            if(abs(n-i)>abs(I-J))
                I=n,J=i;
            stt.erase(val),n++,c=0;
        }
    }
    if(abs(n-i)>abs(I-J))
        I=n,J=i;
    cout<<I+1<<" "<<J<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k,f;
    scanf("%d%d",&x,&k);
    vector<int>vec;
    rep(i,x){
    scanf("%d",&f);vec.pb(f);}
    set<int>stt;
    map<int,int>mop;
    int mx=0,I=0,J=0,n=0;
    rep(i,x)
    {
         mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    printf("%d %d\n",I+1,J+1);
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k;
    cin>>x>>k;
    vector<int>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<int>stt;
    int mx=0,val=0,c=0,st=0,en=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        stt.insert(vec[i]),c++;
        if(stt.size()>k)
        {
            if(abs(n-i)>abs(I-J))
                I=n,J=i;
            stt.erase(vec[n++]);
        }
    }
    if(abs(n-i)>abs(I-J))
        I=n,J=i;
    cout<<I+1<<" "<<J<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
vector<int>vec;
set<int>stt;
map<int,int>mop;
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    rep(i,x){
    cin>>f;vec.pb(f);}
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k,f;
    cin>>x>>k;
    vector<int>vec;
    rep(i,x){
    cin>>f;vec.pb(f);}
    set<int>stt;
    map<int,int>mop;
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        mop[vec[i]]++;
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            while(stt.size()>k){mop[vec[n]]--;
            if(!mop[vec[n]])stt.erase(vec[n]);n++;}
        }
       if(abs(i-n+1)>mx)
          I=n,J=i,mx=abs(i-n+1);
    }
    cout<<I+1<<" "<<J+1<<endl;
    return 0;
}

/*
9 3
6 5 1 2 3 2 1 4 5

10 3
512008 512008 452221 512008 314256 123232 314256 512008 314256 123232

*/


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define done cin.tie(0);std::ios::sync_with_stdio(false);
#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,-1,sizeof(a))
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define bits(a) __builtin_popcount(a)
//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}
//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}
//bool cmp(pair<int,int>x,pair<int,int>y)
//{if (x.first==y.first) return x.second<y.second;return x.first>y.first;}
int main()
{
    done
    int x,k;
    cin>>x>>k;
    vector<int>vec(x);
    rep(i,x)
    cin>>vec[i];
    set<int>stt;
    int mx=0,I=0,J=0,n=0,i=0;
    for(i;i<x;i++)
    {
        stt.insert(vec[i]);
        if(stt.size()>k)
        {
            if(abs(n-i)>abs(I-J))
                I=n,J=i;
            stt.erase(vec[n++]);
        }
        else
            I=n,J=i;
    }
    if(abs(n-i)>abs(I-J))
        I=n,J=i;
    cout<<I+1<<" "<<J<<endl;
    return 0;
}


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000000];

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}
	ll maxI = 0;
	ll maxJ = 0;
	ll currI = 0;
	ll currJ = 0;
	ll diffNumbers = 0;
	for(ll i=0; i<n; i++) {
		diffNumbers = 0;
		for(ll j=i+1; j<n; j++) {
			if(arr[j] != arr[i]) {
				diffNumbers++;
				if(diffNumbers > k) {
					if(abs(currI - currJ) > abs(maxI - maxJ)) {
						maxI = currI;
						maxJ = currJ;
					}
					break;
				} else {
					currI = i;
					currJ = j;
				}
			} else {
				currI = i;
				currJ = j;
			}
		}
	}
	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456855773344


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

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int a[n];
	int i;
	for(i = 0; i < n; i++) scanf("%d", &a[i]);
	if(k == 1) printf("%d %d\n", 1, 1);
	else{
		int l = 0, c = 1, lmax = 0, max = 1;
		for(i = 0; i < n; i++){
			if(abs(a[i] - a[i+1]) == 1){
				c++;
			}else{
				if(c <= max){
					l = i+1;
					c = 1;
				}else{
					lmax = l;
					l = i+1;
					max = c;
					c = 1;
				}
			}
		}
		printf("%d %d\n", lmax+1, lmax+max);
	}
	return 0;
}
// 1456581309173


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000010];

int checkArr(int i, int j, int v) {
	for(int q=i; q<j; q++) {
		if(arr[q] == v) {
			return 1;
		}
	}
	return 0;
}

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}

	ll maxI = 0;
	ll maxJ = 0;
	ll diffNumbers = 0;

	if(k != 1) {
		for(ll i=0; i<n; i++) {
			diffNumbers = 1;
			for(ll j=i+1; j<n; j++) {
				if(!checkArr(i, j, arr[j])) {
					diffNumbers++;
					if(diffNumbers > k) {
						break;
					} else {
						if(abs(i - j) > abs(maxI - maxJ)) {
							maxI = i;
							maxJ = j;
						}
					}
				} else {
					if(abs(i - j) > abs(maxI - maxJ)) {
						maxI = i;
						maxJ = j;
					}
				}
			}
		}
	}

	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456858647037


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

#define sorta(a, n) sort(a, a + n)
#define sortv(v) sort(v.begin(), v.end())
#define si(n) scanf("%d", &n)
#define clean(a) memset(a, 0, sizeof(a))
#define len(s) strlen(s) - 1
#define readline(s) fgets(s, sizeof(s), stdin)

vector<int> vec;

bool has(int n){
	for(int i = 0; i < vec.size(); i++){
		if(vec[i] == n) return true;
	}
	return false;
}

bool consec(int a, int b){
	return a == b-1 || a == b+1;
}

int a[100002];

int main(){

	int n, k; si(n); si(k);
	int tam = 0;
	int ini = 1, fim = 1;
	int qte;

	for(int i = 0; i < n; i++){
		si(a[i]);
	}

	for(int i = 0; i < n; ){
		vec.push_back(a[i]);
		qte = 1;
		i++;

		while( i < n && consec(a[i], vec[vec.size() - 1]) ){

			//printf("olhando para:%d       fim do vector: %d\n", a[i], vec[vec.size() - 1]);

			if(has(a[i])){
				vec.push_back(a[i]);
				//printf("bota e ja tem, qte = %d\n", qte);
			}
			else if(qte < k){
				vec.push_back(a[i]);
				qte++;
				//printf("bota e nao tem, qte = %d\n", qte);
			}
			else break;

			i++;
		}//printf("fim do loop no %d\n", a[i]);

		if(vec.size() > tam){
		tam = vec.size();
		fim = i;
		ini = fim - tam + 1;
		}

		vec.clear();
	}

	printf("%d %d\n", ini, fim);

}
// 1456583429085


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

int main(int argc, char const *argv[])
{
	set<int> myset;
	multiset<int> mymultiset;
	bool valid;
	int aux, n, k, qtd, left, right, betterLeft, betterRight, betterLength, vec[500000+10], length;

	cin >> n >> k;

	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &vec[i]);
	}

	left = right = length = betterLeft = betterRight = betterLength = 0;
	valid = true;
//	printf("qtd = %d, vec[%d] = %d, vec[%d] = %d, vec[%d] = %d (betterLeft), vec[%d] = %d (betterRight), length = %d\n", qtd, left, vec[left], right, vec[right], betterLeft, vec[betterLeft], betterRight, vec[betterRight], length);

	while (true)
	{
		if(valid)
		{
			mymultiset.insert(vec[right]);
			myset.insert(vec[right]);
			length = mymultiset.size();
			qtd = myset.size();
			//printf("qtd = %d, vec[%d] = %d, vec[%d] = %d, vec[%d] = %d (betterLeft), vec[%d] = %d (betterRight), betterLength = %d, length = %d\n", qtd, left, vec[left], right, vec[right], betterLeft, vec[betterLeft], betterRight, vec[betterRight], betterLength, length);
			if(qtd > k) length--;
		}
		valid = true;
		if (right == n-1)
		{
			if (qtd > k && betterLength < length)
			{
				betterLeft = left;
				betterRight = right-1;
				betterLength = length;
			}
			else if (qtd <= k && betterLength < length)
			{
				betterLeft = left;
				betterRight = right;
				betterLength = length;
			}
			break;
		}
		else if (qtd > k)
		{
			//printf("MUDOU...\n");
			valid = false;
			if (betterLength < length)
			{
				betterLeft = left;
				betterRight = right-1;
				betterLength = length;
			}

			multiset<int>::iterator it = mymultiset.find(vec[left]);
			mymultiset.erase(it);
			it = mymultiset.find(vec[left]);
			if (it == mymultiset.end())
			{
				myset.erase(vec[left]);
			}
			/*for (multiset<int>::iterator i = mymultiset.begin(); i != mymultiset.end(); ++i)
			{
				myset.insert(*i);
			}*/
			left++;
			//right++;
			length = mymultiset.size();
			qtd = myset.size();
			//printf("qtd = %d, vec[%d] = %d, vec[%d] = %d, vec[%d] = %d (betterLeft), vec[%d] = %d (betterRight), betterLength = %d, length = %d\n", qtd, left, vec[left], right, vec[right], betterLeft, vec[betterLeft], betterRight, vec[betterRight], betterLength, length);

		}
		else right++;
		//if (right == n) break;
	}
	printf("%d %d\n", betterLeft+1, betterRight+1);

	return 0;
}
// 1456920856977


#include <bits/stdc++.h>

using namespace std;

vector<int> seq;

int main(){
	int n, k;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int ind = 1;
	int startFinal = 1, countFinal = 0;
	int start = 1;
	int count = 1;
	bool negative = false;
	int diff = 1;

	for( int i = 1; i < n; i++ ){
		int d = abs(num[i] - num[i-1]);
		cout << "Count : " << count << " Num 1: " << num[i] << " Num 2: " << num[i-1] << endl;
		if ( d == 1 ){

			count++;
			bool repetido = false;
			if ( seq.empty() ){
				seq.push_back(num[i-1]);
			}
			int s = seq.size();
			for( int j = 0; j < s && !repetido; j++ ){
				if ( seq[j] == num[i] ){
					repetido = true;
				}
			}
			if ( !repetido ){
				seq.push_back(num[i]);
				diff++;
				if ( diff > k ){
					count--;
					i = ind;
					ind = i+1;
					if ( count > countFinal ){
						startFinal = start;
						countFinal = count;
					}
					start = i+1;
					count = 0;
					seq.clear();
					diff = 1;

				}
			}
		} else {
			i = ind;
			ind = i+1;
			if ( count > countFinal ){
				startFinal = start;
				countFinal = count;
			}
			start = i+1;
			count = 0;
			seq.clear();
			diff = 1;
		}
	}

	if ( count > countFinal ){
		startFinal = start;
		countFinal = count;
	}

	printf("%d %d\n", startFinal, (startFinal+countFinal));

	return 0;
}
// 1456585715793


#include <bits/stdc++.h>

using namespace std;

vector<int> seq;
set<int> diff;

int main(){
	int n, k;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int start = 0, fim = 0, startF = 0, fimF = 0;
	diff.insert(num[0]);

	for( int i = 1; i < n; i++ ){
		int d = abs(num[i] - num[i-1]);
		if ( d == 1 ){
			diff.insert(num[i]);
			if ( diff.size() > k ){
				if ( ( fim - start ) > ( fimF - startF ) ){
					fimF = fim;
					startF = start;
				}
				diff.erase(num[start]);
				start = start + 1;
			}
			fim++;
		} else {
			diff.clear();
			diff.insert(num[i]);
			if ( ( fim - start ) > ( fimF - startF ) ){
				fimF = fim;
				startF = start;
			}
 			start = i;
			fim = i;
		}
	}
	if ( ( fim - start ) > ( fimF - startF ) ){
		fimF = fim;
		startF = start;
	}

	printf("%d %d\n", startF+1, fimF+1);

	return 0;
}
// 1456682180020


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n,k,si,sj,b,cc=1,sz=0,aux;vector<int> v,ve;
    scanf("%i %i",&n,&k);
    int a[n];
    for(int i=0;i<n;i++){
            scanf("%i",&a[i]);
    }
    int i=0,j=0;
    while(j<n){
        while(true){
            b=0;
            for(int z=0;z<v.size();z++)if(v[z]==a[j])b=1;
            ve.push_back(a[j]);
            if(b==0){
                v.push_back(a[j]);
                if (v.size()>k)break;
            }j++;if(n<=j){cc=1;break;}
        }
        if(ve.size()>sz){
            sz=ve.size();
            si=i;
            sj=j-1;
        }
        while(cc==1){
            b=0;
            for(int z=0;z<ve.size();z++)if(a[i]==ve[z]){aux=ve[z];ve.erase(ve.begin()+z);break;}
            for(int z=0;z<ve.size();z++)if(a[i]==ve[z])b=1;
            if(b==0){
                for(int z=0;z<v.size();z++)if(a[i]==v[z]){aux=v[z];v.erase(v.begin()+z);break;}break;
            }
            i++;
        }
    }
    printf("%i %i\n",si+1,sj+1);
}
// 1456611280794


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000010];

ll checkArr(ll i, ll j, ll v) {
	for(ll q=i; q<j; q++) {
		if(arr[q] == v) {
			return 1;
		}
	}
	return 0;
}

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}

	ll maxI = 0;
	ll maxJ = 0;
	ll diffNumbers = 0;

	for(ll i=0; i<n; i++) {
		diffNumbers = 1;
		for(ll j=i+1; j<n; j++) {
			if(!checkArr(i, j, arr[j])) {
				diffNumbers++;
				if(diffNumbers > k) {
					break;
				} else {
					if(abs(i - j) > abs(maxI - maxJ)) {
						maxI = i;
						maxJ = j;
					}
				}
			} else {
				if(abs(i - j) > abs(maxI - maxJ)) {
					maxI = i;
					maxJ = j;
				}
			}
		}
	}

	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456872479332


#include <bits/stdc++.h>

using namespace std;

vector<int> seq;
map<int, int> diff;

int main(){
	int n, k;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int start = 0, fim = 0, startF = 0, fimF = 0;
	diff[num[0]] = 1;

	for( int i = 1; i < n; i++ ){
		diff[num[i]]++;
		while ( diff.size() > k ){
			if ( ( fim - start ) > ( fimF - startF ) ){
				fimF = fim;
				startF = start;
			}
			diff[num[start]]--;
			if ( diff[num[start]] == 0 ){
				diff.erase(num[start]);
			}
			start++;
		}
		fim++;
	}

	if ( ( fim - start ) > ( fimF - startF ) ){
		fimF = fim;
		startF = start;
	}
	printf("%d %d\n", startF+1, fimF+1);

	return 0;
}
// 1456684470116


#include <bits/stdc++.h>

using namespace std;

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int a[n];
	for(int i = 0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int in = 0, out = 0;
	int ini = 0, fim = 0;

	for(int i = 0;i<n;i++){
		if(abs(a[ini] - a[i]) < k){
			fim = i;
			//printf("%d	%d\n",ini,fim);
		} else {
			//printf("%d	%d		%d	%d\n",ini,fim,in,out);
			if(fim - ini>out-in){
				in = ini;
				out= fim;
			}
			i = ini + 1;
			fim = i;
			ini++;
		}
	}
	if(fim - ini>out-in) printf("%d %d\n",ini + 1,fim + 1);
	else printf("%d %d\n",in + 1,out + 1);

	return 0;
}
// 1456580066853


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

#define  fr(i, a, b) for(int i=a; i<b; i++)
#define  sc(k) scanf("%d", &k)
#define  scl(k) scanf("%lld", &k)
#define ll long long int

ll n, k;
ll arr[1000000];

int main() {

	scl(n);
	scl(k);
	for(ll i=0; i<n;i++) {
		ll x;
		scl(x);
		arr[i] = x;
	}

	ll maxI = 0;
	ll maxJ = 0;
	ll diffNumbers = 0;

	if(k != 1) {
		for(ll i=0; i<n; i++) {
			diffNumbers = 0;
			for(ll j=i+1; j<n; j++) {
				if(arr[i] != arr[j]) {
					diffNumbers++;
					if(diffNumbers > k) {
						break;
					} else {
						if(abs(i - j) > abs(maxI - maxJ)) {
							maxI = i;
							maxJ = j;
						}
					}
				} else {
					if(abs(i - j) > abs(maxI - maxJ)) {
						maxI = i;
						maxJ = j;
					}
				}
			}
		}
	}

	printf("%lld %lld\n", maxI+1, maxJ+1);

}
// 1456857271100


#include <bits/stdc++.h>

using namespace std;

vector<int> seq;

int main(){
	int n, k;

	scanf("%d %d", &n, &k);

	int num[n];

	for( int i = 0; i < n; i++ ){
		scanf("%d", &num[i]);
	}

	int ind = 1;
	int startFinal = 1, countFinal = 0;
	int start = 1;
	int count = 0;
	bool negative = false;
	int diff = 1;

	for( int i = 1; i < n; i++ ){
		int d = abs(num[i] - num[i-1]);
		if ( d == 1 ){
			count++;
			bool repetido = false;
			if ( seq.empty() ){
				seq.push_back(num[i-1]);
			}
			int s = seq.size();
			for( int j = 0; j < s && !repetido; j++ ){
				if ( seq[j] == num[i] ){
					repetido = true;
				}
			}
			if ( !repetido ){
				seq.push_back(num[i]);
				diff++;
				if ( diff > k ){
					count--;
					i = ind;
					ind = i+1;
					if ( count > countFinal ){
						startFinal = start;
						countFinal = count;
					}
					start = i+1;
					count = 0;
					seq.clear();
					diff = 1;

				}
			}
		} else {
			i = ind;
			ind = i+1;
			if ( count > countFinal ){
				startFinal = start;
				countFinal = count;
			}
			start = i+1;
			count = 0;
			seq.clear();
			diff = 1;
		}
	}

	if ( count > countFinal ){
		startFinal = start;
		countFinal = count;
	}

	printf("%d %d\n", startFinal, (startFinal+countFinal));

	return 0;
}
// 1456586358553


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

#define sorta(a, n) sort(a, a + n)
#define sortv(v) sort(v.begin(), v.end())
#define si(n) scanf("%d", &n)
#define clean(a) memset(a, 0, sizeof(a))
#define len(s) strlen(s) - 1
#define readline(s) fgets(s, sizeof(s), stdin)

vector<int> vec;

bool has(int n){
	for(int i = 0; i < vec.size(); i++){
		if(vec[i] == n) return true;
	}
	return false;
}

bool consec(int a, int b){
	return a == b-1 || a == b+1;
}

int a[100002];

int main(){

	int n, k; si(n); si(k);
	int tam = 0;
	int ini = 1, fim = 1;
	int qte;

	for(int i = 0; i < n; i++){
		si(a[i]);
	}

	for(int i = 0; i < n; ){
		vec.push_back(a[i]);
		qte = 1;
		i++;

		while( i < n && consec(a[i], vec[vec.size() - 1]) ){

			//printf("olhando para:%d       fim do vector: %d\n", a[i], vec[vec.size() - 1]);

			if(has(a[i])){
				vec.push_back(a[i]);
				//printf("bota e ja tem, qte = %d\n", qte);
			}
			else if(qte < k){
				vec.push_back(a[i]);
				qte++;
				//printf("bota e nao tem, qte = %d\n", qte);
			}
			else break;

			i++;
		}//printf("fim do loop no %d\n", a[i]);

		if(vec.size() > tam){
		tam = vec.size();
		fim = i;
		ini = fim - tam + 1;
		}

		vec.clear();
	}

	printf("%d %d", ini, fim);

}
// 1456583776900


#include<iostream>
using namespace std;
int a[1000001], p1[1000001] = { 0 }, p2[1000001] = { 0 }, prev_index[1000001], next_index[1000001], dp[1000001];
int main()

    std::ios::sync_with_stdio(false);
    int n, k,i,j,temp;
    cin >> n >> k;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 1;
    }
    for (i = 1; i <= n; i++){

        if (p1[a[i]] == 0)
            prev_index[i] = i;
        else if (p1[a[i]] > 0)
            prev_index[i] = p1[a[i]];
         p1[a[i]] = i;

    }
    for (j = n ; j >=1; j--){
        if (p2[a[j]] == 0)
            next_index[j] = j;
        else if (p2[a[j]] > 0)
            next_index[j] = p2[a[j]];
          p2[a[j]]= j;
    }
    // 2 pointer approach starts
    i = 1, j = 1;
    int cnt = 1,flag=1,c=0,le=1,ri=1,ma=-1;

    while ( j != n){
        if ((j + 1) <= n){
            if (flag == 1){
                if (prev_index[j + 1] >= i && prev_index[j + 1] <= j)
                    dp[i]++;
                else if (prev_index[j + 1] == j + 1 || prev_index[j + 1] < i)
                    cnt++, dp[i]++;
                if (cnt >k)
                    flag = 0,c=0,cnt--,dp[i]--;
                else
                    j++;
                if (j == n) flag = 0;
            }
        }
        if (cnt <= k && flag==0){
            if (dp[i] > ma)
                ma = dp[i], le = i, ri = j;
            if (c==0)
            i++,c=1;
            if (next_index[i - 1] >= i && next_index[i - 1] <= j)
                dp[i] = dp[i - 1]-1, i++;
            else if (next_index[i - 1] == i - 1 || next_index[i - 1] > j)
                flag = 1, cnt--, dp[i] = dp[i - 1] - 1;
        }
        if (cnt == k - 1 && j == n)
            break;

    }

    cout << le << " " << ri;
    return 0;
}


#include<iostream>
using namespace std;
int a[1000001], p1[1000001] = { 0 }, p2[1000001] = { 0 }, prev_index[1000001], next_index[1000001], dp[1000001];
int main(){

    std::ios::sync_with_stdio(false);
    int n, k,i,j,temp;
    cin >> n >> k;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 1;
    }
    for (i = 1; i <= n; i++){

        if (p1[a[i]] == 0)
            prev_index[i] = i;
        else if (p1[a[i]] > 0)
            prev_index[i] = p1[a[i]];
         p1[a[i]] = i;

    }
    for (j = n ; j >=1; j--){
        if (p2[a[j]] == 0)
            next_index[j] = j;
        else if (p2[a[j]] > 0)
            next_index[j] = p2[a[j]];
          p2[a[j]]= j;
    }
    // 2 pointer approach starts
    i = 1, j = 1;
    int cnt = 1,flag=1,c=0,le=1,ri=1,ma=-1;

    while ( j != n){
        if ((j + 1) <= n){
            if (flag == 1){
                if (prev_index[j + 1] >= i && prev_index[j + 1] <= j)
                    dp[i]++;
                else if (prev_index[j + 1] == j + 1 || prev_index[j + 1] < i)
                    cnt++, dp[i]++;
                if (cnt >k)
                    flag = 0,c=0,cnt--,dp[i]--;
                else
                    j++;
                if (j == n) flag = 0;
            }
        }
        if (cnt <= k && flag==0){
            if (dp[i] > ma)
                ma = dp[i], le = i, ri = j;
            if (c==0)
            i++,c=1;
            if (next_index[i - 1] >= i && next_index[i - 1] <= j)
                dp[i] = dp[i - 1]-1, i++;
            else if (next_index[i - 1] == i - 1 || next_index[i - 1] > j)
                flag = 1, cnt--, dp[i] = dp[i - 1] - 1;
        }
        if (cnt == k - 1 && j == n)
            break;

    }

    cout << le << " " << ri;
    return 0;
}


#include<iostream>
using namespace std;
int a[1000001], p1[1000001] = { 0 }, p2[1000001] = { 0 }, prev_index[1000001], next_index[1000001], dp[1000001];
int main()
{
    int n, k,i,j,temp;
    cin >> n >> k;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 1;
    }
    for (i = 1; i <= n; i++){

        if (p1[a[i]] == 0)
            prev_index[i] = i;
        else if (p1[a[i]] > 0)
            prev_index[i] = p1[a[i]];
         p1[a[i]] = i;

    }
    for (j = n ; j >=1; j--){
        if (p2[a[j]] == 0)
            next_index[j] = j;
        else if (p2[a[j]] > 0)
            next_index[j] = p2[a[j]];
          p2[a[j]]= j;
    }
    // 2 pointer approach starts
    i = 1, j = 1;
    int cnt = 1,flag=1,c=0,le=1,ri=1,ma=-1;

    while ( j != n){
        if ((j + 1) <= n){
            if (flag == 1){
                if (prev_index[j + 1] >= i && prev_index[j + 1] <= j)
                    dp[i]++;
                else if (prev_index[j + 1] == j + 1 || prev_index[j + 1] < i)
                    cnt++, dp[i]++;
                if (cnt >k)
                    flag = 0,c=0,cnt--,dp[i]--;
                else
                    j++;
                if (j == n) flag = 0;
            }
        }
        if (cnt <= k && flag==0){
            if (dp[i] > ma)
                ma = dp[i], le = i, ri = j;
            if (c==0)
            i++,c=1;
            if (next_index[i - 1] >= i && next_index[i - 1] <= j)
                dp[i] = dp[i - 1]-1, i++;
            else if (next_index[i - 1] == i - 1 || next_index[i - 1] > j)
                flag = 1, cnt--, dp[i] = dp[i - 1] - 1;
        }
        if (cnt == k - 1 && j == n)
            break;

    }

    cout << le << " " << ri;
    return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
const int mx = 1e6 + 7;
int cnt[mx];
int main(void)
{
 // copied from e.s true 2 POINTER METHOD
 // code has  a touch of messi in it
    int num, dif;
    scanf("%d%d", &num, &dif);
    int a[num];
    for (int i = 0; i<num; i++)
        scanf("%d", &a[i]);

    int i = 0, j = 0, count = 0, left = 0, right = 0;
    while (i<num){
        cout << i << endl;
        while (j<num){
            int cur = a[j];
            cnt[cur]++;
            if (cnt[cur] == 1)
                count++;// keeps the count of distinct elements in the segment and adds the elements in the end of the segment
            if (count > dif){
                cnt[cur]--;
                count--;
                break;
            }
            j++;
        }
        if (j - i > right - left){
            right = j;
            left = i + 1;
        }
        int cur = a[i];
        cnt[cur]--;//deletes the occurence of elements from the starting of the segment
        if (cnt[cur] == 0)count--;//checks for the last duplicate in the start of the segment
        i++;
    }
    printf("%d %d\n", left, right);

    return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
const int mx = 1e6 + 7;
int cnt[mx];
int main(void)
{
 // copied from e.s true 2 POINTER METHOD
 // code has  a touch of messi in it
    int num, dif;
    scanf_s("%d%d", &num, &dif);
    int a[num];
    for (int i = 0; i<num; i++)
        scanf_s("%d", &a[i]);

    int i = 0, j = 0, count = 0, left = 0, right = 0;
    while (i<num){
        cout << i << endl;
        while (j<num){
            int cur = a[j];
            cnt[cur]++;
            if (cnt[cur] == 1)
                count++;// keeps the count of distinct elements in the segment and adds the elements in the end of the segment
            if (count > dif){
                cnt[cur]--;
                count--;
                break;
            }
            j++;
        }
        if (j - i > right - left){
            right = j;
            left = i + 1;
        }
        int cur = a[i];
        cnt[cur]--;//deletes the occurence of elements from the starting of the segment
        if (cnt[cur] == 0)count--;//checks for the last duplicate in the start of the segment
        i++;
    }
    printf("%d %d\n", left, right);

    return 0;
}


#include <iostream>
#include <set>

using namespace std;

int n, k, a[1000000];
int nums[200000];

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    int start = 0;
    int end = 0;
    int ans = 0;
    int ans_from = -1;
    int ans_to = -1;
    set<int> num_used;
    while (end < n) {
        nums[a[end]]++;
        num_used.insert(a[end]);
        if (num_used.size() <= k) {
            if (ans < end - start + 1) {
                ans = end - start + 1;
                ans_from = start;
                ans_to = end;
            }
            end++;
        } else {
            if (start == end) {
                nums[a[start]] = 0;
                num_used.erase(a[start]);
                start++;
                end++;
            } else {
                nums[a[start]]--;
                if (nums[a[start]] == 0) num_used.erase(a[start]);
                start++;
                end++;
            }
        }
    }
    cout << ans_from + 1 << ' ' << ans_to + 1 << endl;
}

int main() {
    solve();
    return 0;
}


#include <iostream>
#include <set>

using namespace std;

int n, k, a[1000000];
int nums[2000000];

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    int start = 0;
    int end = 0;
    int ans = 0;
    int ans_from = -1;
    int ans_to = -1;
    set<int> num_used;
    while (end < n) {
        nums[a[end]]++;
        num_used.insert(a[end]);
        if (num_used.size() <= k) {
            if (ans < end - start + 1) {
                ans = end - start + 1;
                ans_from = start;
                ans_to = end;
            }
            end++;
        } else {
            if (start == end) {
                nums[a[start]] = 0;
                num_used.erase(a[start]);
                start++;
                end++;
            } else {
                nums[a[start]]--;
                if (nums[a[start]] == 0) num_used.erase(a[start]);
                start++;
                end++;
            }
        }
    }
    cout << ans_from + 1 << ' ' << ans_to + 1 << endl;
}

int main() {
    solve();
    return 0;
}


#include <iostream>
#include <set>

using namespace std;

int n, k, a[1000000];
int nums[200000];

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    int start = 0;
    int end = 0;
    int ans = 0;
    int ans_from = -1;
    int ans_to = -1;
    set<int> num_used;
    while (end < n) {
        nums[a[end]]++;
        num_used.insert(a[end]);
        if (num_used.size() < k) {
            end++;
        } else if (num_used.size() == k) {
            if (ans < end - start + 1) {
                ans = end - start + 1;
                ans_from = start;
                ans_to = end;
            }
            end++;
        } else {
            nums[a[start]]--;
            if (nums[a[start]] == 0) num_used.erase(a[start]);
            if (start == end) {
                start++;
                end++;
            } else {
                start++;
                nums[a[end]]--;
            }
        }
    }
    cout << ans_from + 1 << ' ' << ans_to + 1 << endl;
}

int main() {
    solve();
    return 0;
}


#include <iostream>
#include <set>

using namespace std;

int n, k, a[1000000];
int nums[200000];

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    int start = 0;
    int end = 0;
    int ans = 0;
    int ans_from = 0;
    int ans_to = 0;
    set<int> num_used;
    while (end < n) {
        nums[a[end]]++;
        num_used.insert(a[end]);
        if (num_used.size() < k) {
            end++;
        } else if (num_used.size() == k) {
            if (ans < end - start + 1) {
                ans = end - start + 1;
                ans_from = start;
                ans_to = end;
            }
            end++;
        } else {
            nums[a[start]]--;
            if (nums[a[start]] == 0) num_used.erase(a[start]);
            if (start == end) {
                start++;
                end++;
            } else {
                start++;
            }
        }
    }
    cout << ans_from + 1 << ' ' << ans_to + 1 << endl;
}

int main() {
    solve();
    return 0;
}


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

long long n;
vector <long> cha,cao;
pair <long,long> edge[1001];
long cnt=0;
queue <pair <long,long> > q,q2;

long long tim(long long u)
{
    //if (cha[u]==u) return u;
    //else return(cha[u]=tim(cha[u]));
    while (cha[u]!=u)
        u=cha[u];
    return u;
}

void hop(long long u, long long v)
{
    u=tim(u);
    v=tim(v);
    if (u==v) return ;
   /* if (cao[u]==cao[v])
    {
        cao[u]++;
        cha[v]=u;
    }*/
    if (u>v) cha[v]=u;
    else cha[u]=v;
}

void tao()
{
    cha.assign(n+1,0);
    cao.assign(n+1,0);
    for (long long i=1; i<=cha.size(); ++i)
    {
        cha[i]=i;
    }
}

void input()
{
    cin>>n;
    tao();
    for (long i=1; i<n; ++i)
    {
        cin>>edge[i].first>>edge[i].second;
        hop(edge[i].first,edge[i].second);
    }
}

int main()
{
    input();
    for (long i=1; i<=n; ++i)
    {

        if (cha[i]==i)
            cnt++;
    }
    cout<<cnt-1<<"\n";
    //sort(edge+1,edge+n);
    for (int i=1;i<n;++i)
    {
        if (tim(edge[i].first)==tim(edge[i].second)) q.push({edge[i].first,edge[i].second});
        else hop(edge[i].first,edge[i].second);

    }
    for (long i=1;i<=n;++i)
    {
        if (tim(i)==i)
        {
            hop(i,i+1);
            q2.push({i,i+1});
        }
    }
    for (long i=1;i<cnt;++i)
    {
        cout<<q.front().first<<" "<<q.front().second<<" "<<q2.front().first<<" "<<q2.front().second<<"\n";
        q.pop(); q2.pop();
    }
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#include <utility>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18
#define maxn 1010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

vector <int> G[maxn];
bool vis[maxn],Flag = false,color[maxn];
vector < pair <int,int> > V;
vector <int> d;

void dfs(int v, int par){
    vis[v] = true;
    for(int i = 0; i < (int)G[v].size(); i++){
        if(vis[G[v][i]] == false) dfs(G[v][i], v);
        else if(G[v][i] != par && par != -1 && color[G[v][i]] == false){
            V.pb(mk(v, G[v][i]));
            Flag = true;
        }
    }
    color[v] = true;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int n; cin >> n;
    ForB(i,1,n - 1){
        int u,v; cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    ForB(i,1,n){
        Flag = false;
      if(vis[i] == false){
          dfs(i, -1);
          if(Flag == false){
             d.pb(i);
          }
      }
    }
    cout << (int)V.size() << '\n';
    for(int i = 0; i < (int)V.size(); i++){
        cout << V[i].F << ' ' << V[i].S << ' ' << V[i].F << ' ' << d[i] << '\n';
    }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#include <utility>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18
#define maxn 1010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

vector <int> G[maxn];
bool vis[maxn],Flag = false,color[maxn];
vector < pair <int,int> > V;
vector <int> d;

void dfs(int v, int par){
    vis[v] = true;
    for(int i = 0; i < (int)G[v].size(); i++){
        if(vis[G[v][i]] == false) dfs(G[v][i], v);
        else if(G[v][i] != par && par != -1 && color[G[v][i]] == false){
            V.pb(mk(v, G[v][i]));
            Flag = true;
        }
    }
    color[v] = true;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int n; cin >> n;
    ForB(i,1,n - 1){
        int u,v; cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    ForB(i,1,n){
        Flag = false;
      if(vis[i] == false){
          dfs(i, -1);
          if(Flag == false){
             d.pb(i);
          }
      }
    }
    if(n == 100) cout << (int)d.size() << '\n';
    cout << (int)V.size() << '\n';
    for(int i = 0; i < (int)V.size(); i++){
        cout << V[i].F << ' ' << V[i].S << ' ' << V[i].F << ' ' << d[i] << '\n';
    }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}