#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n,k,r;
cin >> n >> k >> r;
vector<ll> lst(n+1);
vector<ll> Occurences(k);
vector<ll> Requirement(k,0);
for(ll i=1;i<=n;i++){
cin >> lst[i];
Occurences[lst[i]]++;
}
ll ye=0;
for(ll i=0;i<r;i++){
ll b,q;
cin >> b >> q;
Requirement[b]=q;
if(Requirement[b]>Occurences[b]){
ye=1;
}
}
if(ye==1){
cout << "impossible" << "\n";
return 0;
}
ll L=1;
vector<ll> Count(k,0);
ll Good=0;
ll ans=LLONG_MAX;
for(ll R=1;R<=n;R++){
ll num=lst[R];
Count[num]++;
if(Requirement[num]>0 and Count[num]==Requirement[num]){
Good++;
}
while(Good==r){
ans=min(ans,R-L+1);
ll Removal=lst[L];
if(Requirement[Removal]>0 and Count[Removal]==Requirement[Removal]){
Good--;
}
Count[Removal]--;
L++;
}
}
cout << ans;
}