#include <bits/stdc++.h>
#define int long long
#define arr3 array <int , 3>
#define pii pair <int , int>
#define fi first
#define se second
#define BIT(x , k) ((x >> k)&1)
#define MASK(x) (1 << x)
using namespace std;
const int maxn = 2e6 + 7;
const int INF = 1e18;
int n , a[maxn] , cnt[maxn] , no = 0 , k , r , req[maxn];
void solve()
{
cin >> n >> k >> r;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= r; i++)
{
int b , q; cin >> b >> q;
if(req[b] == 0) no++;
req[b] = max(req[b] , q);
}
int j = 1;
int ans = INF;
for(int i = 1; i <= n; i++)
{
no -= (cnt[a[i]] < req[a[i]]);
cnt[a[i]]++;
no += (cnt[a[i]] < req[a[i]]);
if(no > 0) continue;
while(true)
{
if(cnt[a[j]] - 1 < req[a[j]]) break;
j++;
cnt[a[j]]--;
}
if(no == 0) ans = min(ans , i - j + 1);
}
if(ans == INF) cout << "impossible" << '\n';
else cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
//freopen("inp.txt" , "r" , stdin); freopen("out.txt" , "w", stdout);
//int tc; cin >> tc; while(tc--) solve();
solve();
return 0;
}