#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fs first
#define sc second
using namespace std;
const int N = 2e5 + 5;
int a[N], freq[N], b[N];
signed main(){
int n, k, rr;
cin >> n >> k >> rr;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < rr; i++) {
int x, q;
cin >> x >> q;
b[x] = q;
}
int l = 0, cnt = 0, ans = 1e18;
for (int r = 0; r < n; r++) {
freq[a[r]]++;
if (freq[a[r]] == b[a[r]]) cnt++;
while (cnt == rr) {
ans = min(ans, r - l + 1);
if (freq[a[l]] == b[a[l]]) cnt--;
freq[a[l]]--;
l++;
}
}
if (cnt < rr) {
cout << "impossible" << endl;
return 0;
}
cout << ans << endl;
}