#include using namespace std; const int NMax = 1e3 + 5; int v[NMax], D[NMax], Best[NMax], B[NMax]; pair < int, int > A[NMax]; int main(){ /*#ifndef ONLINE_JUDGE freopen("debug.in", "r", stdin); #endif // ONLINE_JUDGE*/ //freopen("a.in", "r", stdin); int n, m, d, x, y; cin >> d >> n >> m; for(int i = 1; i <= n; i++){ cin >> v[i]; } for(int i = 1; i <= m; i++){ cin >> x >> y; A[i] = {x, y}; } sort(A + 1, A + m + 1); for(int i = 1; i <= m; i++){ for(int j = 1; j <= n; j++){ if(v[j] >= A[i].first && v[j] <= A[i].second){ D[i]++; } } } Best[1] = D[1]; B[1] = 1; for(int i = 2; i <= m; i++){ if(D[i]){ Best[i] = D[i]; B[i] = 1; for(int j = i - 1; j > 0; j--){ if(D[j]){ if(A[i].first > A[j].second){ if(Best[j] + D[i] == Best[i]){ B[i] = min(B[i], B[j] + 1); } if(Best[j] + D[i] > Best[i]){ Best[i] = Best[j] + D[i]; B[i] = B[j] + 1; } } } } } } int Min = INFINITY; for(int i = 1; i <= m; i++){ if(Best[i] == n){ Min = min(Min, B[i]); } } cout << Min; return 0; }