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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

class praca
{
public:
	
int L;
vector<int> T;

bool operator<(const praca &c) const
{
vector<int>::const_iterator it_a,it_b;

	it_a = this->T.begin();
	it_b = c.T.begin();
	while (it_a != this->T.end())
	{
		if ((*it_a) != (*it_b)) return (*it_a) < (*it_b);
		++it_a;
		++it_b;
	}
	
	return this->L < c.L;
}

};

int main()
{
int N,n,M,m,p,x;
praca pr;
map<praca,int> PR;
map<praca,int>::iterator PRi;

	scanf("%d %d",&N,&M);
	
	pr.L = 1;
	for (n = 0; n < N; n++)
	{
		scanf("%d",&m);
		pr.T.push_back(m);
	}
	
	PR.insert(pair<praca,int>(pr,0));
	for (m = 0; m < M-1; m++)
	{
		scanf("%d %d",&p,&x);
		pr.L++;
		pr.T[p-1] = x;
		PR.insert(pair<praca,int>(pr,0));
	}
	
	for (PRi = PR.begin(); PRi != PR.end(); ++ PRi)
	{
		printf("%d ",PRi->first.L);
	}
	printf("\n");
	
	return 0;
}