#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int target[200005];
int freq[200005];
int a[200005];
int main()
{
int n,k,r;
cin>>n>>k>>r;
for(int i = 0; i < n; i++) cin>>a[i];
for(int i = 0; i < r; i++)
{
int x,y;
cin>>x>>y;
target[x] = y;
}
int l = 0;
int ans = 1e9, cur = 0;
for(int i = 0; i < n; i++)
{
freq[a[i]]++;
if(freq[a[i]] == target[a[i]]) cur++;
while(cur == r && l <= i)
{
ans = min(ans, i-l+1);
freq[a[l]]--;
if(freq[a[l]] < target[a[l]]) cur--;
l++;
}
}
if(ans == 1e9) cout<<"impossible";
else cout<<ans;
}