#include #define FOREACH(it,c) for( __typeof((c).begin()) it=(c).begin();it!=(c).end();it++) #define FOR(a,b,c) for(int a=(b);a<=(c);++a) #define ROF(a,b,c) for(int a=(b);a>=(c);--a) #define dbg(x) cout<<#x<<" = "<<(x)<<"\n"; #define pii pair #define pil pair< pair< int, int> , ind > #define mp make_pair #define pb push_back #define fi first.first #define se first.second #define ind second #define ll long long #define TATA NULL using namespace std; const int NMAX = 100002; int x[NMAX], y[NMAX], dp[NMAX], mark[NMAX]; int main(){ #ifndef ONLINE_JUDGE freopen("data.in","r",stdin); #endif // ONLINE_JUDGE cin.sync_with_stdio(false); cin.tie(TATA); int n,d,m; cin >> d >> n >> m; for(int i=1;i<=n;i++) { int x; cin >> x; mark[x] = 1; } int last = 0; for(int i=1;i<=m;i++) cin >> x[i] >> y[i]; for(int i=1;i<=d;i++) { if(mark[i]) last = i; if(last == 0) continue; dp[i] = 10000; for(int j=1;j<=m;j++) { if(x[j] <= last && last <= y[j] && y[j] <= i) dp[i] = min(dp[i],1+dp[x[j]-1]); } } cout<