1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <bits/stdc++.h>
#define ll long long
#define pii pair <int,int>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, p, x;
    cin >> n >> m;
    vector < vector <int> > W(m, vector <int> (n+1));
    for(int i=0; i<n; i++)
        cin >> W[0][i];
    W[0][n]=1;
    for(int i=1; i<m; i++){
        cin >> p >> x;
        for(int j=0; j<n; j++)
            W[i][j]=W[i-1][j];
        W[i][p-1]=x;
        W[i][n]=i+1;
    }
    sort(W.begin(),W.end());
    for(int i=0; i<m; i++)
        cout << W[i][n] << " ";
    cout <<"\n";
    return 0;
}