#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair i_i; template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long long INF = 1e18; //const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; assert(1 <= N and N <= 10000); assert(0 <= M and M <= 100000); for(int i = 0; i < N; i++) { ll B; cin >> B; assert(-1000000000 <= B and B <= 1000000000); } set st; for(int i = 0; i < M; i++) { ll l, r; cin >> l >> r; assert(1 <= l and l <= r and r <= N); l_l tmp = {l, r}; assert(st.find(tmp) == st.end()); st.insert(tmp); } return 0; }