#include <bits/stdc++.h>
#pragma GCC optimize("O3", "Ofast")
#define int long long
#define ll long long
#define se second
#define fi first
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 5e5+10;
const int MAXA = 5e4+10;
const int SQRT = 300;
const ll INF = 2e18;
const int MOD = 1e9+7;
const int LOG = 32;
ll sum(auto a, auto b){
ll te = a+MOD+b;
for(; te >= MOD; ) te -= MOD;
return te;
}
void chsum(auto &a, auto b){ a = sum(a,b); }
ll mul(auto a, auto b){ return 1ll*a*b%MOD; }
void chmul(auto &a, auto b){ a = mul(a,b); }
void chmn(auto &a, auto b){ a = min(a, b); }
void chmx(auto &a, auto b){ a = max(a, b); }
ll expo(int a, int b){
if(b==0) return 1;
ll te = expo(a, b/2); te = mul(te,te); // temporary -> te
return (b%2 ? mul(te, a) : te);
}
vector <int> dx = {0, 0, -1, 1};
vector<int> dy = {-1, 1, 0, 0};
int T, n, a[MAXN], cnt[MAXN];
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>T>>n;
int tot = 0;
for(int i=1; i<=n; i++){
cin>>a[i];
if(cnt[a[i]] == 1) tot++;
cnt[a[i]]++;
}
int mx = -1, l=1, r=1, las = 0;
for(int i=1; i<=n; i++){
while(las<i || (las<n && tot > 0)){
++las; cnt[a[las]]--;
if(cnt[a[las]] == 1) tot--;
}
// cout << i << ' '<< las << ' '<< tot << " las\n";
if(tot == 0){
if(mx < n-(las-i+1)){
l = i; r = las; mx = n-(las-i+1);
}
}
cnt[a[i]]++;
if(cnt[a[i]] == 2) tot++;
}
cout << l-1 << ' '<< r-1 << '\n';
}