//In the name of God
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int N = 1e6 + 6;

int n, m, ans[N], state[N], f[2 * N], x[N], y[N];
bool mark[N];

void update(int m, int c) { m = N - m - 2;
	while (m < 2 * N)
		f[m] += c, m += m & -m;
}
int query(int m) { m = N - m - 2;
	int res = 0;
	while (m)
		res += f[m], m -= m & -m;
	return res;
}
bool acc(int d, int cur) {
	int l = d + query(d + 1);
	if (l != cur)
		return l < cur;
	return ans[d] == -1;
}
void EXIT() {
	cout << -1 << '\n';
	exit(0);
}
int main() {
	fill(ans, ans + N, -1);
	scanf("%d%d", &n, &m);
//	cerr << '\n';
	for (int i = 0; i < m; i++) {
		scanf("%d%d", x + i, y + i);
		if (mark[x[i]]++)
			continue;
		int st = 1, ed = n + 1;
		while (ed - st > 1) {
			int mid = st + ed >> 1;
			(acc(mid, y[i])? st: ed) = mid;
		}
		if (acc(st, y[i])) {
			ans[st] = x[i];
			update(st, 1);
		}
		else
			EXIT();
	}
	for (int p1 = 1, p2 = 1; p1 <= n; p1++)
		if (!mark[p1]) {
			while (ans[p2] != -1)
				p2++;
			ans[p2] = p1;
		}
//	for (int i = 1; i <= n; i++)
//		cerr << ans[i] << ' ';
//	cerr << '\n';
	for (int i = 1; i <= n; i++)
		state[ans[i]] = i;
	fill(f, f + 2 * N, 0);
	for (int i = 1; i <= n; i++)
		update(i, 1);
	for (int i = 0; i < m; i++)
		if (y[i] == n - query(state[x[i]] + 1)) {
			update(state[x[i]], -1);
			state[x[i]] = -i - 1;
			update(state[x[i]], 1);
		}
		else
			EXIT();
	for (int i = 1; i <= n; i++)
		printf("%d ", ans[i]);
	printf("\n");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

default_random_engine engine(time(nullptr));
uniform_int_distribution<int> dist(0, 1e9);
auto random = bind(dist, engine);

struct Node {
    int y;
    int sz;
    int i;
    Node* l;
    Node* r;

    Node(int ii) :
        y(random()), sz(1), i(ii), l(nullptr), r(nullptr) {}
};

int getSz(Node* u) {
    if (u) {
        return u->sz;
    }
    return 0;
}

Node* merge(Node* l, Node* r) {
    if (!l) {
        return r;
    }
    if (!r) {
        return l;
    }
    Node* u;
    if (l->y > r->y) {
        l->r = merge(l->r, r);
        u = l;
    } else {
        r->l = merge(l, r->l);
        u = r;
    }
    u->sz = getSz(u->l) + getSz(u->r) + 1;
    return u;
}

void split(Node* u, int k, Node*& l, Node*& r) {
    if (!u) {
        l = nullptr;
        r = nullptr;
        return;
    }
    if (k > getSz(u->l)) {
        split(u->r, k - getSz(u->l) - 1, u->r, r);
        l = u;
    } else {
        split(u->l, k, l, u->l);
        r = u;
    }
    u->sz = getSz(u->l) + getSz(u->r) + 1;
}

const int N = 1e6 + 1;

Node* root = nullptr;

int n;
int trueIndexes[N];
bool used[N];

void build() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        root = merge(root, new Node(i));
    }
}

void solve() {
    int m;
    cin >> m;
    while (m--) {
        int x, y;
        cin >> x >> y;
        Node* l;
        Node* m;
        split(root, y, l, root);
        split(l, y - 1, l, m);
        if (trueIndexes[m->i]) {
            if (trueIndexes[m->i] != x) {
                cout << -1;
                exit(0);
            }
        } else {
            if (used[x]) {
                cout << -1;
                exit(0);
            } else {
                trueIndexes[m->i] = x;
                used[x] = true;
            }
        }
        root = merge(merge(m, l), root);
    }
    for (int i = 1, j = 1; i <= n; ++i) {
        if (trueIndexes[i]) {
            continue;
        }
        while (used[j]) {
            ++j;
        }
        used[j] = true;
        trueIndexes[i] = j;
    }
}

void write() {
    for (int i = 1; i <= n; ++i) {
        cout << trueIndexes[i] << ' ';
    }
}

void solveTest() {
    build();
    solve();
    write();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    solveTest();

    return 0;
} // не ругайся((()

//Author: Romanov Artem
#include <bits/stdc++.h>
#include <cinttypes>
#include <algorithm>
#include <string>
#include <fstream>
#include <iostream>
#include <ctime>
#include <array>
//#define IN "input.txt"
//#define OUT "output.txt"

#define PI 3.14159265358979323846L
#define E 2.71828182845904523536L
#define EPS 1e-12L
#define D_INF HUGE_VALL
#define D_NINF (-HUGE_VALL)
#define T_MAX(T) std::numeric_limits<T>::max()
#define T_MIN(T) std::numeric_limits<T>::min()
#define m_p make_pair
#define r_s random_shuffle
#define l_b lower_bound
#define u_b upper_bound
#define e_r equal_range
#define b_s binary_search
#define s_u set_union
#define s_i set_intersection
#define s_d set_difference
#define l_c lexicographical_compare
#define n_p next_permutation
#define p_p prev_permutation
#define F first
#define S second
#define j0 j57552
#define j1 j77461
#define jn j29628
#define y0 y84678
#define y1 y53021
#define yn y91675

using namespace std;
typedef long double dbl;

template< typename TK, typename TV >
struct node {
    int priority;
    TK key;
    TV value;
    size_t size;
    node< TK, TV >* left;
    node< TK, TV >* right;

    node(const int& priority,
         const TK& key = TK(),
         const TV& value = TV(),
         node< TK, TV >* left = nullptr,
         node< TK, TV >* right = nullptr)
            : priority(priority)
            , key(key)
            , value(value)
            , size(1)
            , left(left)
            , right(right) { }

    node() : node(rand()) { }
};

template< typename TV >
struct node< void, TV> {
    int priority;
    TV value;
    size_t size;
    node< void, TV>* left;
    node< void, TV>* right;

    node(const int& priority,
         const TV& value = TV(),
         node< void, TV>* left = nullptr,
         node< void, TV>* right = nullptr)
            : priority(priority)
            , value(value)
            , size(1)
            , left(left)
            , right(right) { }

    node() : node(rand()) { }
};

template< typename TK, typename TV >
size_t subtree_size(node< TK, TV >* t) {
    return (t == nullptr ? 0 : t->size);
}

template< typename TK, typename TV >
void update(node< TK, TV >* t) {
    if (t != nullptr) {
        t->size = subtree_size(t->left) + subtree_size(t->right) + 1;
    }
}

template< typename TK, typename TV >
void split(node< TK, TV >* t, const TK& key, node< TK, TV >*& left, node< TK, TV >*& right) {
    if (t == nullptr) {
        left = nullptr;
        right = nullptr;
    } else if (key < t->key) {
        split(t->left, key, left, t->left);
        right = t;
    } else {
        split(t->right, key, t->right, right);
        left = t;
    }
    update(t);
}

template< typename TV >
void split(node< void, TV >* t, const size_t& key, node< void, TV >*& left, node< void, TV >*& right, const size_t& add = 0) {
    if (t == nullptr) {
        left = nullptr;
        right = nullptr;
    } else if (key <= add + subtree_size(t->left)) {
        split(t->left, key, left, t->left, add);
        right = t;
    } else {
        split(t->right, key, t->right, right, add + 1 + subtree_size(t->left));
        left = t;
    }
    update(t);
}

template< typename TK, typename TV >
void merge(node< TK, TV >*& t, node< TK, TV >* left, node< TK, TV >* right) {
    if (left == nullptr) {
        t = right;
    } else if (right == nullptr) {
        t = left;
    } else if (left->priority > right->priority) {
        merge(left->right, left->right, right);
        t = left;
    } else {
        merge(right->left, left, right->left);
        t = right;
    }
    update(t);
}

template< typename TK, typename TV >
class treap {

public:
    treap(const size_t& capacity = 131072U, bool genPrios = true) : _cap(capacity) {
        _data = new node< TK, TV >[_cap];
        if (genPrios) {
            int *_prio = new int[_cap];
            for (int i = 0; i < _cap; ++i) {
                _prio[i] = i;
            }
            random_shuffle(_prio, _prio + _cap);
            for (size_t i = 0; i < _cap; ++i) {
                _data[i] = node<TK, TV>(_prio[i]);
            }
            delete[](_prio);
        }
    }

    ~treap() {
        delete[](_data);
    }

    size_t capacity() {
        return _cap;
    }

    node< TK, TV >*& root() {
        return _root;
    }

    node< TK, TV>* data() {
        return _data;
    };

    size_t size() {
        return _cnt;
    }

    node< TK, TV >* find(const TK& key) {
        return find_recursive(key, _root);
    }

    node< TK, TV >* insert(const TK& key, const TV& value) {
        node< TK, TV >* res = find(key);
        if (res != nullptr) {
            res->value = value;
            return res;
        } else {
            _data[_cur].key = key;
            _data[_cur].value = value;
            insert_recursive(_root, &_data[_cur]);
            _cnt++;
            return &_data[_cur++];
        }
    }

    node< TK, TV >* erase(const TK& key) {
        node< TK, TV >* res = find(key);
        if (res == nullptr) {
            return nullptr;
        } else {
            _cnt--;
            return erase_recursive(_root, key);
        }
    }

private:
    size_t _cap{0};
    size_t _cur{0};
    size_t _cnt{0};
    node< TK, TV >* _data{nullptr};
    node< TK, TV >* _root{nullptr};

    node< TK, TV >* find_recursive(const TK& key, node< TK, TV >* t) {
        if (t == nullptr) {
            return nullptr;
        } else if (key < t->key) {
            return find_recursive(key, t->left);
        } else if (key > t->key) {
            return find_recursive(key, t->right);
        } else {
            return t;
        }
    }

    void insert_recursive(node< TK, TV >*& t, node< TK, TV >* item) {
        if (t == nullptr) {
            t = item;
        } else if (item->priority > t->priority) {
            split(t, item->key, item->left, item->right);
            t = item;
        } else {
            insert_recursive(item->key < t->key ? t->left : t->right, item);
        }
        update(t);
    }

    node< TK, TV >* erase_recursive(node< TK, TV >*& t, const TK& key) {
        node< TK, TV >* tmp;
        if (key == t->key) {
            tmp = t;
            merge(t, t->left, t->right);
        } else {
            tmp = erase_recursive(key < t->key ? t->left : t->right, key);
            update(t);
        }
        return tmp;
    }
};

template< typename TV >
class treap< void, TV > {

public:
    treap(const size_t& capacity = 131072U, bool genPrios = true) : _cap(capacity) {
        _data = new node< void, TV >[_cap];
        if (genPrios) {
            int *_prio = new int[_cap];
            for (int i = 0; i < _cap; ++i) {
                _prio[i] = i;
            }
            random_shuffle(_prio, _prio + _cap);
            for (size_t i = 0; i < _cap; ++i) {
                _data[i] = node<void, TV>(_prio[i]);
            }
            delete[](_prio);
        }
    }

    ~treap() {
        delete[](_data);
    }

    size_t capacity() {
        return _cap;
    }

    node< void, TV >*& root() {
        return _root;
    }

    node< void, TV>* data() {
        return _data;
    };

    size_t size() {
        return _cnt;
    }

    node< void, TV >* find(const size_t& key) {
        return find_recursive(key, _root);
    }

    node< void, TV >* insert(const size_t& key, const TV& value) {
        node< void, TV >* res = find(key);
        if (res != nullptr) {
            res->value = value;
            return res;
        } else {
            _data[_cur].value = value;
            insert_recursive(key, _root, &_data[_cur]);
            _cnt++;
            return &_data[_cur++];
        }
    }

    node< void, TV >* erase(const size_t& key) {
        node< void, TV >* res = find(key);
        if (res == nullptr) {
            return nullptr;
        } else {
            _cnt--;
            return erase_recursive(_root, key);
        }
    }

    void output(int* m1, int* m2, node< void, TV >* t) {
        if (t != nullptr) {
            if (t->value.F != -1) {
                if (m1[t->value.S] || m2[t->value.F]) {
                    printf("-1\n");
                    exit(0);
                } else {
                    //m2[t->]
                    m1[t->value.S] = t->value.F;
                    m2[t->value.F] = t->value.S;
                }
            }
            output(m1, m2, t->left);
            output(m1, m2, t->right);
        }
    }

private:
    size_t _cap{0};
    size_t _cur{0};
    size_t _cnt{0};
    node< void, TV >* _data{nullptr};
    node< void, TV >* _root{nullptr};

    node< void, TV >* find_recursive(const size_t& key, node< void, TV >* t, const size_t& add = 0) {
        if (t == nullptr) {
            return nullptr;
        }
        size_t cur_key = 1 + add + subtree_size(t->left);
        if (key < cur_key) {
            return find_recursive(key, t->left, add);
        } else if (key > cur_key) {
            return find_recursive(key, t->right, cur_key);
        } else {
            return t;
        }
    }

    void insert_recursive(const size_t& key, node< void, TV >*& t, node< void, TV >* item, const size_t& add = 0) {
        if (t == nullptr) {
            t = item;
        } else if (item->priority > t->priority) {
            split(t, key, item->left, item->right);
            t = item;
        } else {
            size_t cur_key = 1 + add + subtree_size(t->left);
            if (key < cur_key) {
                insert_recursive(key, t->left, item, add);
            } else {
                insert_recursive(key, t->right, item, cur_key);
            }
        }
        update(t);
    }

    node< void, TV >* erase_recursive(node< void, TV >*& t, const size_t& key, const size_t& add = 0) {
        node< void, TV >* tmp;
        size_t cur_key = 1 + add + subtree_size(t->left);
        if (key == cur_key) {
            tmp = t;
            merge(t, t->left, t->right);
        } else if (key < cur_key) {
            tmp = erase_recursive(t->left, key, add);
            update(t);
        } else {
            tmp = erase_recursive(t->right, key, cur_key);
            update(t);
        }
        return tmp;
    }
};

treap< void, pair< int, int > > t(1024000, false);
int n, m;
node< void, pair< int, int > > *ln1, *ln2, *rn1, *rn2;
pair< int, int > a[1024000];
int ans[1024000];
int res[1024000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(11);
    cout.setf(ios::fixed);
    srand((uint32_t) time(nullptr));
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
    #ifdef IN
    freopen(IN, "r", stdin);
#endif
#ifdef OUT
    freopen(OUT, "w", stdout);
#endif
#endif

    scanf("%i %i", &n, &m);
    for (size_t i = 1; i <= n; ++i) {
        t.insert(i, m_p(-1, i));
    }
    for (int i = 0; i < m; ++i) {
        scanf("%i %i", &a[i].F, &a[i].S);
        //t.find((size_t) a[i].S);
        split(t.root(), (size_t) a[i].S, ln1, rn1);
        split(ln1, (size_t) a[i].S - 1, ln2, rn2);
        if (rn2->value.F == -1 || rn2->value.F == a[i].F) {
            rn2->value.F = a[i].F;
            merge(ln1, rn2, ln2);
            merge(t.root(), ln1, rn1);
        } else {
            printf("-1\n");
            exit(0);
        }
    }
    memset(ans, 0, 1024000 * sizeof(int));
    memset(res, 0, 1024000 * sizeof(int));
    t.output(ans, res, t.root());
    for (int j = 1, i = 1; j <= n, i <= n;) {
        if (!ans[i]) {
            if (!res[j]) {
                ans[i] = j;
                res[j] = i;
                i++; j++;
            } else {
                j++;
            }
        } else {
            i++;
        }
    }
    for (int i = 1; i <= n; ++i) {
        printf("%i ", ans[i]);
    }
    return 0;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>

using namespace std;
const int MOD = 1000000007; // check!!!
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

int fastMin(int x, int y) { return (((y - x) >> (32 - 1))&(x^y)) ^ x; }
int fastMax(int x, int y) { return (((y - x) >> (32 - 1))&(x^y)) ^ y; }
ll fastMin(ll x, ll y) { return (((y - x) >> (64 - 1))&(x^y)) ^ x; }
ll fastMax(ll x, ll y) { return (((y - x) >> (64 - 1))&(x^y)) ^ y; }

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

// 1-indexed
template<class T>
class BIT {
	T bit[ten(6) * 3 + 100];
	int n;

public:
	BIT() {}

	BIT(int N) {
		clear(N);
	}

	void clear(int N) {
		n = N;
		memset(bit, 0, sizeof(bit));
	}

	T sum(int i) {
		T s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, T x) {
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

int index[ten(6) * 3 + 100];
BIT<int> bit;

int main() {
	memset(index, -1, sizeof(index));
	int n, m;
	scanf("%d%d", &n, &m);
	bit.clear(ten(6) * 2 + 30);
	FOR(i, n) bit.add(m + 1 + i, 1);

	bool ok = true;
	vector<int> ans(n);
	FOR(i, m) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (index[x] == -1) {
			int l = 1, r = m + n + 10;
			while (r - l != 1) {
				int md = (l + r) / 2;
				if (bit.sum(md) < y) l = md;
				else r = md;
			}
			if (r - m - 1 < 0) {
				ok = false;
				break;
			}
			ans[r - m - 1] = x;
			index[x] = r;
		}
		int cur_index = bit.sum(index[x]);
		if (cur_index != y) {
			ok = false;
			break;
		}
		bit.add(index[x], -1);
		index[x] = m - i;
		bit.add(index[x], 1);
	}

	if (!ok) {
		puts("-1");
		return 0;
	}

	vector<int> fr;
	FOR(i, n) {
		if (index[i + 1] == -1) fr.push_back(i + 1);
	}
	int cnt = 0;
	FOR(i, n) {
		if (ans[i] == 0) ans[i] = fr[cnt++];
	}
	FOR(i, n) {
		printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
	}

	return 0;
}

#include <cstdio>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <sstream>
using namespace std;

#define DB(x) cerr<<#x<<"="<<x<<" "
#define DBN(x) cerr<<#x<<"="<<x<<"\n"
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

#define INF 1000000000
#define EPS (double)1e-9
#define MOD 1000000007
#define PI 3.14159265358979328462
const int MAX_N = 1000000 + 10;
struct Node {
    Node*ch[2], *p;
    int val, size;
    Node() {
	size = 0;
	val = -INF;
    }
    bool d() {
	return this == p->ch[1];
    }
    void setc(Node*c, int d) {
	ch[d] = c;
	c->p = this;
    }
    void upd() {
	size = ch[0]->size + ch[1]->size + 1;
    }
} Tnull, *null = &Tnull;	// null->p 是没有的
Node mem[MAX_N], *C = mem;

Node*make(int v) {
    C->ch[0] = C->ch[1] = null;
    C->val = v;
    C->size = 1;
    return C++;
}
Node*build(int l, int r) { //[l, r)
    if (l >= r)
	return null;
    int m = (l + r) >> 1;
    Node*t = make(m);
    t->setc(build(l, m), 0);
    t->setc(build(m + 1, r), 1);
    t->upd();
    return t;
}
Node*root;
Node*rot(Node*t) {
    Node*p = t->p;
    int d = t->d();
    p->p->setc(t, p->d());
    p->setc(t->ch[!d], d);
    t->setc(p, !d);
    p->upd();
    if (p == root)
	root = t;
}
void splay(Node*t, Node*f = null) {
    while (t->p != f) {
	if (t->p->p == f)
	    rot(t);
	else
	    t->d() == t->p->d() ? (rot(t->p), rot(t)) : (rot(t), rot(t));
    }
    t->upd();
}
Node* select(int k) {		// [0, n+1] you must splay after select
    for (Node*t = root;;) {
	int c = t->ch[0]->size;
	if (k == c)
	    return t;
	if (k > c)
	    k -= c + 1, t = t->ch[1];
	else
	    t = t->ch[0];
    }
}
Node*get(int l, int r) { //[l,r) R->ch[0] 才是答案
    Node*L = select(l - 1);
    Node*R = select(r);
    splay(L);
    splay(R, L);
    return R;			//
}
int n, m;
int ans[MAX_N];
int wei[MAX_N];
int main(int argc, char *argv[])
{
    scanf("%d%d", &n, &m);
    root = build(0, n+2);
    root->p = null;
    bool succ = true;
    for (int i = 0; i < m; i++) {
    	int id, pos;
    	scanf("%d%d", &id, &pos);
    	Node*t = get(pos, pos+1);
    	Node*tt = t->ch[0];
	if (ans[id] && ans[id] != tt->val) { succ = false; break; }
	if (wei[tt->val] && wei[tt->val] != id) { succ = false; break;}
	ans[id] = tt->val;
	wei[tt->val] = id;
    	t->ch[0] = null; t->upd();
    	Node*ttt = get(1, 1);
    	ttt->setc(tt, 0); ttt->upd();
    }
    if (succ) {
	vector<int> a;
	for (int i = 1; i <= n; i++)
	    if (ans[i] == 0) a.push_back(i);
	int cnt = 0;
    	for (int i = 1; i <= n; i++)
	    if (wei[i])
		printf("%d ", wei[i]);
	    else
		printf("%d ", a[cnt++]);
    	puts("");
    } else
    	puts("-1");
    return 0;
}

#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>

#define US unordered_set

#include <math.h>

#include <unordered_set>
using namespace std;

class Solution {
public:

	struct Node {
		int v;
		int y;
		int count;
		Node* left;
		Node* right;
		Node(int yValue) : v(-1), y(yValue), count(0), left(nullptr), right(nullptr)
		{}

		static int getCount(Node* node) {
			return node == nullptr ? 0 : node->count;
		}

		static void updateCount(Node* node) {
			node->count = 1 + getCount(node->left) + getCount(node->right);
		}

		static Node* merge(Node* leftNode, Node* rightNode) {
			if (leftNode == nullptr || rightNode == nullptr) {
				Node* ans = leftNode == nullptr ? rightNode : leftNode;
				updateCount(ans);
				return ans;
			}

			if (leftNode->y > rightNode->y) {
				leftNode->right = merge(leftNode->right, rightNode);
				updateCount(leftNode);
				return leftNode;
			}
			else {
				rightNode->left = merge(leftNode, rightNode->left);
				updateCount(rightNode);
				return rightNode;
			}
		}

		static void split(Node* node, int index, Node*& leftNode, Node*& rightNode) {
			if (node == nullptr) {
				leftNode = rightNode = nullptr;
				return;
			}
			else if (getCount(node->left) + 1 <= index) {
				split(node->right, index - 1 - getCount(node->left), node->right, rightNode), leftNode = node;
			}
			else {
				split(node->left, index, leftNode, node->left), rightNode = node;
			}
			updateCount(node);
		}

		static void getValues(Node* node, vector<int>& values){
			if (node == nullptr)return;
			getValues(node->left, values);
			values.emplace_back(node->v);
			getValues(node->right, values);
		}
	};

    void solve(int num, std::istream& in, std::ostream& out) {
		int n, m; in >> n >> m;
		vector<pair<int, int>> op;
		for (int i = 0; i < m; i++) {
			int x, y; in >> x >> y;
			x--, y--;
			op.emplace_back(x, y);
		}
		reverse(op.begin(), op.end());
		vector<int> order(n);
		for (int i = 0; i < n; i++) {
			order[i] = i;
		}
		Node* treap = nullptr;
		for (int i = 0; i < n; i++) {
			/*int rIndex = i + (rand() % (n - i));
			swap(order[i], order[rIndex]);*/
			Node* nextNode = new Node(rand()/*order[i]*/);
			treap = Node::merge(treap, nextNode);
		}
		US<int> used;
		for (auto p : op) {
			Node* leftNode;
			Node* rightNode;
			Node::split(treap, p.second + 1, leftNode, rightNode);

			Node* first;
			Node::split(leftNode, 1, first, leftNode);
			if (first->v == -1) {
				if (used.count(p.first)) {
					out << -1 << endl; return;
				}
				first->v = p.first;
			}
			else {
				if (first->v != p.first) {
					out << -1 << endl; return;
				}
			}
			used.insert(p.first);
			treap = Node::merge(Node::merge(leftNode, first), rightNode);
		}

		vector<int> values;
		Node::getValues(treap, values);
		used.clear();
		for (auto x : values) {
			used.insert(x);
		}
		int idx = 0;
		for (auto x : values) {
			if (x != -1) {
				out << x + 1 << " ";
			}
			else {
				while (used.count(idx)) {
					idx++;
				}
				idx++;
				out << idx << " ";
			}
		}
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
	//int T; in >> T;
	//for(int i = 0;i < T;i++)
		//solution.solve(i+1, in, out);
	solution.solve(0, in, out);
}

#include <fstream>
#include <iostream>

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    istream& in = cin;

    ostream& out = cout;

    solve(in, out);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;

#define DB(v) cerr << #v << ": " << v << endl
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define fore(i, a, b) for (int i = a; i <= (int)b; ++i)
#define ford(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define clear(x) memset(x, 0, sizeof(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int MAXN = 1e6 + 7;

struct Tree
{
    Tree()
        :prior(rand() * RAND_MAX + rand()), size(1),
         id(-1), left(NULL), right(NULL)
    {}
    int prior, size, id;
    Tree *left, *right;
};

typedef Tree* ptree;

int getSize(ptree t) { return t ? t->size : 0; }
void update(ptree t)
{
    if (t) {
        t->size = getSize(t->left) + getSize(t->right) + 1;
    }
}

void merge(ptree& t, ptree l, ptree r)
{
    if (!l || !r) {
        t = l ? l : r;
    } else {
        if (l->prior > r->prior) {
            merge(l->right, l->right, r);
            t = l;
        } else {
            merge(r->left, l, r->left);
            t = r;
        }
    }
    update(t);
}

void split(ptree t, ptree& l, ptree& r, int key)
{
    if (!t) {
        l = r = NULL;
    } else {
        int x = getSize(t->left);
        if (x <= key) {
            split(t->right, t->right, r, key - x - 1);
            l = t;
        } else {
            split(t->left, l, t->left, key);
            r = t;
        }
    }
    update(t);
}

bool used[MAXN];
vector<int> ans;

void print(ptree t)
{
    if (t) {
        print(t->left);
        ans.pb(t->id);
        print(t->right);
    }
}

int n, m;
int aa[MAXN], bb[MAXN];

void scan()
{
    scanf("%d%d", &n, &m);
    forn(i, m) {
        scanf("%d%d", aa + m - 1 - i, bb + m - 1 - i);
        --bb[m - 1 - i];
    }
}

void solve()
{
    ptree root = NULL;
    forn(i, n) {
        merge(root, root, new Tree());
    }

    forn(i, m) {
        int id = aa[i];
        int pos = bb[i];

        ptree a, b, c;
        split(root, a, c, pos);
        split(a, a, b, 0);

        if (!(a->id == -1 || a->id == id) || (a->id == -1 && used[id])) {
            printf("-1\n");
            return;
        } else {
            a->id = id;
            used[id] = true;
        }

        merge(root, b, a);
        merge(root, root, c);
    }
    print(root);

    int last = 1;
    forn(i, n) {
        if (ans[i] == -1) {
            while (used[last])
                ++last;
            ans[i] = last++;
        }
        printf("%d ", ans[i]);
    }
}

int main()
{
#ifdef HOME
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    scan();
    solve();

#ifdef HOME
    cerr << "\nTime elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}

#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>

using namespace std;

struct treap{
    treap *l, *r;
    int v, s, y;
    treap(){
        l = r = NULL;
        s = 1;
        y = rand();
        v = -1;
    }
};

int size(treap *t){
    if (t == NULL)
        return 0;
    return t->s;
}

void upd(treap *t){
    if (t == NULL)
        return;
    t->s = 1 + size(t->l) + size(t->r);
}

treap * merge(treap *l, treap *r){
    if (l == NULL)
        return r;

    if (r == NULL)
        return l;

    if (l->y > r->y){
        l->r = merge(l->r, r);
        upd(l);
        return l;
    }

    if (l->y <= r->y){
        r->l = merge(l, r->l);
        upd(r);
        return r;
    }
}

void split(int c, treap *t, treap *&l, treap *&r){
    if (t == NULL){
        l = NULL;
        r = NULL;
        return;
    }

    if (size(t->l) + 1 <= c){
        split(c - size(t->l) - 1, t->r, t->r, r);
        l = t;
        upd(l);
    }
    else{
        split(c, t->l, l, t->l);
        r = t;
        upd(r);
    }
}

#define M 1000100

int n, m, x[M], y[M];
treap t[M];
treap *root = NULL;
bool bad, u[M];
vector<int> fr;

void read(void){
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i)
        scanf("%d%d", x + i, y + i);
}

void ini(void){
    for (int i = 0; i < n; ++i){
        root = merge(root, t + i);
        //cout << size(root) << "!\n";
    }

}

void kill(void){
    treap *f, *l, *r;

    for (int i = m - 1; i >= 0; --i){
        split(1, root, f, root);
        split(y[i] - 1, root, l, r);

        if (f->v == -1){
            if (u[x[i]]){
                bad = 1;
                break;
            }
            f->v = x[i];
        }

        u[x[i]] = 1;

        if (f->v != x[i]){
            bad = 1;
            break;
        }

        root = merge(l, merge(f, r));
    }

    if (bad){
        printf("-1\n");
        return;
    }

    for (int i = 1; i <= n; ++i)
    if (!u[i])
        fr.push_back(i);

    int k = 0;

    for (int i = 1; i <= n; ++i){
        split(1, root, f, root);
        if (f->v == -1)
            f->v = fr[k++];
        printf("%d ", f->v);
    }
}

int main(){
#ifdef GORILLA
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#else
#endif
    srand(34560);

    read();
    ini();
    kill();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//*find_by_order: iterator to kth elem (0-indexed)
//order_of_key: # of items < k (stictly less)

using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const int inf = 1e9;

template<typename T> struct segtree {

    T merge(T x, T y) {
	x += y;
	return x;
    }
    int n;
    vector<ll> t;
    void init(int n) {
	n += 10;
	this->n = n;
	t.resize(n*4);
    }

    void upd(int v, int tl, int tr, int i, T dx) {
	if (tl == tr) {
	    t[v] = merge(t[v], dx);
	} else {
	    int tm = (tl+tr)/2;
	    if (i<=tm) {
		upd(2*v,tl,tm,i,dx);
	    } else {
		upd(2*v+1,tm+1,tr,i,dx);
	    }
	    t[v] = merge(t[2*v], t[2*v+1]);
	}
    }

    T qry(int v, int tl, int tr, int l, int r) {
	if (l>tr || r<tl) {
	    return 0;
	}
	if (l <= tl && tr <= r) {
	    return t[v];
	}
	int tm = (tl+tr)/2;
	return merge(qry(2*v,tl,tm,l,r), qry(2*v+1,tm+1,tr,l,r));
    }

    int walk(int v, int tl, int tr, int pos) {
	if (tl==tr) {
	    return tl;
	} else {
	    int tm=(tl+tr)/2;
	    if (tm+1+t[2*v+1] <= pos) {
		return walk(2*v+1,tm+1,tr,pos);
	    } else {
		return walk(2*v,tl,tm,pos-t[2*v+1]);
	    }
	}
    }
};

int n,m;
int inds[maxn];
pair<int,int> Q[maxn];
bool used[maxn];

segtree<int> sg;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    memset(inds,-1,sizeof(inds));

    cin>>n>>m;
    sg.init(n+10);

    for (int z=0; z<m; z++) {
	int val, pos;
	cin>>val>>pos;
	Q[z] = make_pair(val, pos);
	if (~inds[val]) continue;

	int og = sg.walk(1,1,n,pos);
	if (og + sg.qry(1,1,n,og,n) != pos) out(-1);

	inds[val] = og;
	sg.upd(1,1,n,og,+1);

	used[val]=true;
    }

    ordered_set<int> os;
    vector<int> mp(n+1, inf);
    int cloc=0;

    for (int z=0; z<m; z++) {
	int val = Q[z].first;
	int pos = Q[z].second;
	if (mp[val] < inf) {
	    int rank = os.order_of_key(mp[val]);
	    if (rank != pos-1) {
		out(-1);
	    }
	    os.erase(mp[val]);
	}
	mp[val]=cloc;
	os.insert(cloc);
	cloc--;
    }

    vector<int> ans(n+10, -1);
    for (int x=1; x<=n; x++) {
	if (inds[x] != -1) {
	    ans[inds[x]] = x;
	}
    }

    for (int i=1,j=1; i<=n; i++) {
	if (ans[i] == -1) {
	    while (used[j]) j++;
	    assert(j<=n);
	    ans[i]=j;
	    used[j]=true;
	}
    }

    for (int i=1; i<=n; i++) {
	cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

#include<cassert>
#include<cstdio>
#include<new>
using namespace std;
const int maxn=1000000+5;
unsigned ran()
{
    static unsigned x=20160306;
    return x=x*0xdefaced+1;
}
struct Node
{
    static Node mem[maxn];
    Node *lc,*rc;
    int pri,id,pos,size;
    void pull() {size=(lc?lc->size:0)+(rc?rc->size:0)+1;}
    Node() {}
    Node(int x) {pri=ran();id=-1;lc=rc=NULL;pos=x;size=1;}
}*root,Node::mem[maxn],*pmem=Node::mem;
Node* merge(Node* a,Node* b)
{
    if(!a || !b) return a?a:b;
    else if(a->pri > b->pri)
    {
        a->rc=merge(a->rc,b);
        a->pull();
        return a;
    }
    else
    {
        b->lc=merge(a,b->lc);
        b->pull();
        return b;
    }
}
void split(Node* t,int k,Node*& a,Node*& b)
{
    if(!t) {a=b=NULL;return;}
    else if(((t->lc?t->lc->size:0)+1)<=k)
    {
        a=t;
        split(t->rc,k-(t->lc?t->lc->size:0)-1,a->rc,b);
        a->pull();
    }
    else
    {
        b=t;
        split(t->lc,k,a,b->lc);
        b->pull();
    }
}
Node *t1,*t2,*t3;
int ans[maxn],show[maxn],cnt=1;
void dfs(Node* now)
{
    if(!now) return;
    dfs(now->lc);
    if(now->id!=-1) ans[now->pos]=now->id;
    else
    {
        while(show[cnt]) cnt++;
        ans[now->pos]=cnt;
        show[cnt]=1;
    }
    dfs(now->rc);
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) root=merge(root,new (pmem++) Node(i));
    bool flag=1;
    for(int i=0,id,pos;i<m;i++)
    {
        scanf("%d%d",&id,&pos);
        if(!flag) continue;
        split(root,pos-1,t1,t2);
        split(t2,1,t2,t3);
        assert(t2);
        if(t2->id!=-1 && t2->id!=id) {flag=0;continue;}
        if(show[id]!=0 && show[id]!=t2->pos) {flag=0;continue;}
        t2->id=id;show[id]=t2->pos;
        root=merge(t2,merge(t1,t3));
    }
    if(!flag) {printf("-1\n");return 0;}
    dfs(root);
    for(int i=1;i<=n;i++) printf("%d%c",ans[i],i==n?'\n':' ');
}

#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define REP(i,s,e) for(i=(s); i < (e); i++)
#define REB(i,s,e) for(i=(s); i >= (e); i--)
using namespace std;
#define MAX_SIZE 1000111
// stores the key that each item holds at the moment
vector<int> pos[MAX_SIZE];
bool visited[MAX_SIZE];

inline void out(int x){
    if(x>=10){
        out(x/10);
    }
    putchar(x%10+'0');
}

inline int read()
{
    int fu=1,k=0;
    char a=getchar();
    while(a<'0'||a>'9')
    {
        if(a=='-')fu=-1;
        a=getchar();
    }
    while(a>='0'&&a<='9')
    {
        k=k*10+a-'0';
        a=getchar();
    }
    return fu*k;
}

struct SBST {
    struct node {
    	struct node *left, *right;
    	int value;
    	int id;
    	int size;
    	short height;
    	node(int val, int id) {
    		this->left = this->right = NULL;
    		this->value = val;
    		this->id = id;
    		this->height = 0;
    		this->size = 1;
    	}
    };

    short height(node *t) {
    	if (t == NULL) return -1;
    	return t->height;
    }

    int size(node *t) {
    	if (t == NULL) return 0;
    	return t->size;
    }

    node *leftrotate(node *t) {
    	if (t == NULL || t->right == NULL) return t;
    	node *tmp = t->right;
    	t->right = tmp->left;
    	t->height = 1 + max(height(t->left), height(t->right));
    	t->size = 1 + size(t->left) + size(t->right);
    	tmp->left = t;
    	tmp->height = 1 + max(height(tmp->left), height(tmp->right));
    	tmp->size = 1 + size(tmp->left) + size(tmp->right);
    	return tmp;
    }

    node *rightrotate(node *t) {
    	if (t == NULL || t->left == NULL) return t;
    	node *tmp = t->left;
    	t->left = tmp->right;
    	t->height = 1 + max(height(t->left), height(t->right));
    	t->size = 1 + size(t->left) + size(t->right);
    	tmp->right = t;
    	tmp->height = 1 + max(height(tmp->left), height(tmp->right));
    	tmp->size = 1 + size(tmp->left) + size(tmp->right);
    	return tmp;
    }

    node *balance(node *t) {
    	if (t == NULL) return t;
    	t->height = 1 + max(height(t->left), height(t->right));
    	t->size = 1 + size(t->left) + size(t->right);
    	int hl = height(t->left), hr = height(t->right);
    	if (hl - hr > 1) {
    		if (height(t->left->left) < height(t->left->right)) {
    			t->left = leftrotate(t->left);
    		}
    		t = rightrotate(t);
    	} else if (hr - hl > 1) {
    		if (height(t->right->right) < height(t->right->left)) {
    			t->right = rightrotate(t->right);
    		}
    		t = leftrotate(t);
    	}
    	return t;
    }

    node *getval(node *t, int val) {
    	if (t == NULL) return NULL;
    	if (t->value == val) return t;
    	if (t->value < val) {
    		return getval(t->right, val);
    	}

    	return getval(t->left, val);
    }

    node *insertion(node *t, int val, int id) {
    	if (t == NULL) return new node(val, id);
    	if (t->value == val) return t;
    	if (t->value < val) {
    		t->right = insertion(t->right, val, id);
    	} else {
    		t->left = insertion(t->left, val, id);
    	}

    	t = balance(t);
    	return t;
    }

    node *deletion(node *t, int val) {
    	if (t == NULL) return t;
    	if (t->value == val) {
    		node * tmp;
    		if (t->left == NULL && t->right == NULL) {
    			//delete t;
    			return NULL;
    		} else if (t->left == NULL) {
    			tmp = t->right;
    			//delete t;
    			return tmp;
    		} else if (t->right == NULL) {
    			tmp = t->left;
    			//delete t;
    			return tmp;
    		} else {
    			tmp = t->left;
    			while (tmp->right != NULL) {
    				tmp = tmp->right;
    			}
    			t->value = tmp->value;
    			t->id = tmp->id;
    			t->left = deletion(t->left, tmp->value);
    		}
    	} else if (t->value < val) {
    		t->right = deletion(t->right, val);
    	} else {
    		t->left = deletion(t->left, val);
    	}
    	t = balance(t);
    	return t;
    }

    node *getkth(node *t, int k) {
    	if (t == NULL) return NULL;
    	if (size(t->left) + 1 == k) {
    		return t;
    	} else if (size(t->left) + 1 < k) {
    		return getkth(t->right, k - size(t->left) - 1);
    	}
    	return getkth(t->left, k);
    }

    node *root = NULL;

    int n;
    void init(int n) {
        this->n = n;
        int i;
        REP(i, 0, n) {
            root = insertion(root, i, 0);
        }
    }

    // return whether this operation has a contradiction
    bool movefront(int id, int k) {
        auto c = getkth(root, k);
        if (!visited[id]) {
            pos[id].push_back(c->value);
        }
        // add code here for invalid cases
        // case 1, the kth position contains a cup with different id
        if (c->id != 0 && id != c->id) {

            return false;
        }
        // case 2, the cup already has a position, but now the position
        // is not k
        if (!pos[id].empty() && pos[id].back() != c->value) {

            return false;
        }
        visited[id] = true;
        // erase the key and insert it at the front
        int v = getkth(root, 1)->value;
        root = insertion(root, v - 1, id);
        pos[id].push_back(v-1);
        root = deletion(root, c->value);
        return true;
    }

    // note that this function can only be called when id is the 1st cup
    void movecorrect(int id) {
        root = deletion(root, pos[id].back());
        pos[id].pop_back();
        root = insertion(root, pos[id].back(), id);
    }

    int idx = 0;
    int curr[MAX_SIZE];

    void preorder(node *t) {
        if (t == NULL) return;
        preorder(t->left);
        if (t->id == 0) {
            out(curr[idx++]);
            putchar(' ');
        } else {
            out(t->id);
            putchar(' ');
        }
        preorder(t->right);
    }

    void print() {
        int i, j = 0;
        REP(i, 1, n + 1) {
            if (!visited[i]) {
                curr[j++] = i;
            }
        }

        idx = 0;
        preorder(root);
        printf("\n");
    }
};

SBST st;
int oper[MAX_SIZE];

int main() {
    int i, n, m;
    int v, pos;
    n = read(), m = read();
    st.init(n);
    REP(i, 0, m) {
        v = read(), pos = read();
        oper[i] = v;
        if (!st.movefront(v, pos)) {
            printf("-1\n");
            return 0;
        }
    }

    REB(i, m-1, 0) {
        st.movecorrect(oper[i]);
    }

    st.print();
    return 0;
}//hellobig_tq

//Immanuel
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
typedef long long LL;
int bit[2000005];
int n,m,all;

inline void add(int x,int v)
{
    for(;x<=all;x+=x&-x) bit[x]+=v;
}

inline int read(int x)
{
    int res=0;
    for(;x;x^=x&-x) res+=bit[x];
    return res;
}

inline int get_kth(int k)
{
    int idx=0;
    for(int i=20;i>=0;--i)
    {
        idx^=1<<i;
        if(idx<=all&&bit[idx]<k) k-=bit[idx];
        else idx^=1<<i;
    }
    return idx+1;
}

int pos[1000005],ans[1000005],num[2000005];
int main()
{
    scanf("%d%d",&n,&m);
    all=n+m;
    for(int i=1;i<=n;++i)
    {
        add(m+i,1);
        num[m+i]=i;
    }
    int top=m;
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        int t=get_kth(y);
        if(pos[x]&&pos[x]!=num[t])
        {
            puts("-1");
            return 0;
        }
        if(ans[num[t]]&&ans[num[t]]!=x)
        {
            puts("-1");
            return 0;
        }
        pos[x]=num[t];
        ans[num[t]]=x;
        add(t,-1);
        add(top,1);
        num[top--]=num[t];
    }
    for(int j=1,i=1;i<=n;++i)
    {
        if(ans[i]) printf("%d ",ans[i]);
        else
        {
            for(;j<=n&&pos[j];++j);
            printf("%d ",j++);
        }
    }
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <time.h>
#include <set>
#include <assert.h>

using namespace std;
struct A
{
    int nxl,nxr;
    int ans,where;
    int sz,pri;
}Node[2000005];
int ans[2000005]={0};
bool have[1000005]={0};
int Merge(int a,int b)
{
    if(a==0) return b;
    if(b==0) return a;
    if(Node[a].pri>Node[b].pri)
    {
        Node[a].nxr=Merge(Node[a].nxr,b);
        Node[a].sz=Node[Node[a].nxl].sz+Node[Node[a].nxr].sz+1;
        return a;
    }
    else
    {
        Node[b].nxl=Merge(a,Node[b].nxl);
        Node[b].sz=Node[Node[b].nxl].sz+Node[Node[b].nxr].sz+1;
        return b;
    }
}
pair < int , int > split(int here,int con)
{
    pair < int , int > t;
    if(here==0) return make_pair(0,0);
    if(con<=(Node[Node[here].nxl].sz))
    {
        t=split(Node[here].nxl,con);
        Node[here].nxl=t.second;
        Node[here].sz=Node[Node[here].nxl].sz+Node[Node[here].nxr].sz+1;
        t.second=here;
    }
    else
    {
        t=split(Node[here].nxr,con-Node[Node[here].nxl].sz-1);
        Node[here].nxr=t.first;
        Node[here].sz=Node[Node[here].nxl].sz+Node[Node[here].nxr].sz+1;
        t.first=here;
    }
    return t;
}
int main()
{
    srand(time(NULL));
    pair < int , int > t,t2;
    int N,M,a,b,root=0,now=1,ok=1,i,tt;
    scanf("%d %d",&N,&M);
    Node[0].sz=0;
    for(i=0;i<N;i++)
    {
        Node[now].pri=rand();
        Node[now].where=i;
        Node[now].ans=0;
        Node[now].nxl=0;
        Node[now].nxr=0;
        Node[now].sz=1;
        root=Merge(root,now);
        now++;
    }
    while(M--)
    {
        scanf("%d %d",&b,&a);
        t=split(root,a-1);
        t2=split(t.second,1);
        if(Node[t2.first].ans==b)
        {
            root=Merge(Merge(t2.first,t.first),t2.second);
            continue;
        }
        else if(have[b]) ok=0;
        else if(Node[t2.first].ans==0)
        {
            Node[t2.first].ans=b;
            have[b]=1;
            ans[Node[t2.first].where]=b;
        }
        else ok=0;
        root=Merge(Merge(t2.first,t.first),t2.second);
    }
    //if(N==1000000) return 0;
    if(!ok) printf("-1\n");
    else
    {
        tt=1;
        for(i=0;i<N;i++)
        {
            if(ans[i]==0)
            {
                while(have[tt]) tt++;
                have[tt]=1;
                printf("%d ",tt);

            }
            else printf("%d ",ans[i]);
        }
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

struct node {
	int val;
	int prior;
	node *left = NULL, *right = NULL;
	int dyd;
	node(int v) {
		val = v;
		prior = rand();
		dyd = 1;
	}
	void fix() {
		dyd = 1;

		if (left) {
			dyd += left->dyd;
		}

		if (right) {
			dyd += right->dyd;
		}
	}
	int mazl() {
		return 1 + (left ? left->dyd : 0);
	}
};

void print(node *&d) {
	if (d == NULL)
		return;

	print(d->left);
	cout << d->val << " ";
	print(d->right);
}

void merge(node *&d, node *l, node *r) {
	if (l == NULL)
		d = r;
	else if (r == NULL)
		d = l;
	else if (l->prior > r->prior) {
		d = l;
		merge(d->right, l->right, r);
		d->fix();
	}
	else {
		d = r;
		merge(d->left, l, r->left);
		d->fix();
	}
}

void split(node *d, int k, node *&l, node *&r) {
	if (d == NULL) {
		l = r = NULL;
	}
	else if (d->mazl() <= k) {
		split(d->right, k - d->mazl(), d->right, r);
		l = d;
		d->fix();
	}
	else {
		split(d->left, k, l, d->left);
		r = d;
		d->fix();
	}
}

/*link https://codeforces.com/group/nIDHK2OChY/contest/254094/problem/A */
/*input
2 1
2 1
*/
/*output
2 1
*/
/*input
3 2
1 2
1 1
*/
/*output
2 1 3
*/
/*input
3 3
1 3
2 3
1 3
*/
/*output
-1
*/

int main () {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	node *root = NULL;
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		merge(root, root, new node(i));
	}

	vector<int> konv(n, -1), atgal(n, -1);

	// print(root);
	// cout << endl;

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		node *a, *b, *c;
		split(root, y - 1, a, b);
		split(b, 1, b, c);
		int z = b->val;
		merge(root, b, a);
		merge(root, root, c);

		if ((atgal[z] == x or atgal[z] == -1) and (konv[x] == z or konv[x] == -1)) {
			atgal[z] = x;
			konv[x] = z;
		}
		else {
			cout << "-1";
			exit(0);
		}

		// print(root);
		// cout << endl;
	}

	int it = 0;

	for (auto && j : atgal) {
		if (j == -1) {
			while (konv[it] != -1) {
				it++;
			}

			it++;
			cout << it << " ";
		}
		else {
			cout << j + 1 << " ";
		}
	}
}

#include <bits/stdc++.h>

using namespace std;

struct Tree {
    int pr, cnt;
    int val, num;
    Tree *l, *r;
    Tree() : pr(rand()), cnt(1), val(-1), l(0), r(0) {
        static int d = 0;
        num = d;
        d++;
    }
    Tree(int c) : pr(rand()), cnt(1), val(c), l(0), r(0) {
        static int d = 0;
        num = d;
        d++;
    }
};

int cnt(Tree *t) {
    if(!t) return 0;
    return t->cnt;
}

Tree *update_cnt(Tree *t) {
    t->cnt = cnt(t->l) + cnt(t->r) + 1;
    return t;
}

Tree *merge(Tree *t1, Tree *t2) {
    if(!t1) return update_cnt(t2);
    if(!t2) return update_cnt(t1);
    if(t1->pr > t2->pr) {
            t1->r = merge(t1->r, t2);
            return update_cnt(t1);
    }
    t2->l = merge(t1, t2->l);
     return update_cnt(t2);
}

pair <Tree*, Tree*> split(Tree *t, int key, int add = 0) {
    if(!t) return make_pair((Tree*)(NULL), (Tree*)(NULL));
    int pr_key = cnt(t->l) + add + 1;
    pair <Tree*, Tree*> r;
    if(key < pr_key) {
        r = split(t->l, key, add);
        t->l = r.second;
        r.second = t;
    } else {
        r = split(t->r, key, pr_key);
        t->r = r.first;
        r.first = t;
    }
    update_cnt(t);
    return r;
}

int getVal(Tree *t, int key, int add = 0) {
    if(!t) return -1;
    int pr_key = add + cnt(t->l) + 1;
    if(pr_key == key) return t->val;
    if(pr_key >= key) {
        return getVal(t->l, key, add);
    }
    return getVal(t->r, key, pr_key);
}

void printe(Tree *t) {
    if(!t) return;
    printe(t->l);
    printf("%d(%d)  ", t->val, t->cnt);
    printe(t->r);
}

Tree *getCPY(Tree *t) {
    if(!t) return NULL;
    Tree *t1 = new Tree(*t);
    t1->l = getCPY(t->l);
    t1->r = getCPY(t->r);
    return t1;
}

void del(Tree *t) {
    if(!t) return;
    del(t->l);
    del(t->r);
    delete t;
}

Tree *mas[1234560];
int ans[1234560];
int gg[1234560];
int main() {
    memset(&gg, 0, sizeof(gg));
    memset(&ans, 255 ,sizeof(ans));
    int n, m;
    set <int> zn;
    set <int>::iterator it;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) {
        mas[i] = new Tree(-1);
        //zn.insert(i+1);
    }
    Tree *t(NULL);
    for(int i = 0; i < n; i++) {
        t = merge(t, mas[i]);
    }
    pair <Tree*, Tree*> u, p;
    int x, y;
    for(int i = 0; i < m; i++) {
        scanf("%d%d", &x, &y);
        u = split(t, y-1);
        p = split(u.second, 1);
        if(p.first->val != -1 && p.first->val != x) {
            printf("-1");
            return 0;
        }
        p.first->val = x;
        t = merge(merge(p.first, u.first), p.second);
    }
    for(int i = 0; i < n; i++) {
        if(mas[i]->val == -1) continue;
        gg[mas[i]->val-1]++;
        if(gg[mas[i]->val-1] > 1) {
            printf("-1");
            return 0;
        }
    }
    int j = 0;
    while(gg[j]) j++;
    for(int i = 0; i < n; i++) {
        ans[mas[i]->num] = mas[i]->val;
        if(mas[i]->val == -1) {
            ans[mas[i]->num] = j+1;
            gg[j]++;
            while(gg[j])j++;
        }
    }

    for(int i = 0; i < n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

#define NN 1100000

struct Node {

	int sz, val;

	Node *ls, *rs, *fa;

};

int used;

Node buf[2*NN];

int p[NN], vst[NN], cnt;

int a[NN], b[NN];

struct Splay_Tree {

	Node *root, *NIL;

	Node *create_node(int x){

		Node *node=&buf[used++];

		node->sz=1;

		node->val=x;

		node->ls=node->rs=node->fa=NIL;

		return node;

	}

	void init(){

		used=0;

		NIL=create_node(0); NIL->sz=0;

		Node *x=create_node(-1);

		Node *y=create_node(-1);

		x->rs=y; y->fa=x; root=x;

		update(x);

	}

	void update(Node *x){

		x->sz = x->ls->sz + x->rs->sz + 1;

	}

	void zig(Node *x){

		Node *y=x->rs, *p=x->fa;

		x->rs=y->ls; y->ls->fa=x;

		y->ls=x; x->fa=y; y->fa=p;

		if(p==NIL) root=y;

		else if(p->ls==x) p->ls=y;

		else p->rs=y;

		update(x);

	}

	void zag(Node *x){

		Node *y=x->ls, *p=x->fa;

		x->ls=y->rs; y->rs->fa=x;

		y->rs=x; x->fa=y; y->fa=p;

		if(p==NIL) root=y;

		else if(p->rs==x) p->rs=y;

		else p->ls=y;

		update(x);

	}

	void splay(Node *x, Node *g){

		Node *y, *z;

		while(x->fa!=g){

			y=x->fa; z=y->fa;

			if(z==g){

				if(x==y->rs) zig(y);

				else zag(y);

			}

			else if(y==z->rs){

				if(x==y->rs) zig(z), zig(y);

				else zag(y), zig(z);

			}

			else {

				if(x==y->rs) zig(y), zag(z);

				else zag(z), zag(y);

			}

		}

		update(x);

	}

	Node *find(Node *x, int k){

		if(k<=x->ls->sz) return find(x->ls, k);

		if(k==x->ls->sz+1) return x;

		return find(x->rs, k-x->ls->sz-1);

	}

	Node *insert(int k, int val){

		Node *x=create_node(val);

		Node *z=find(root, k);

		Node *y=find(root, k+1);

		splay(z, NIL); splay(y, z);

		x->fa=y; y->ls=x;

		update(y); update(z);

		return x;

	}

	int remove(int k){

		Node *z=find(root, k), *y=find(root, k+2);

		splay(z, NIL); splay(y, z);

		int ans=y->ls->val;

		y->ls=NIL;

		update(y); update(z);

		return ans;

	}

	void print(Node *x){

		if(x==NIL) return ;

		print(x->ls);

		if(x->val>=0) p[cnt++]=x->val;

		print(x->rs);

	}

} Splay;

int main() {

	int n, m;

	cin >> n >> m;

	Splay.init();

	for(int i=1; i<=n; i++){

		Splay.insert(i, 0);

	}

	for(int i=0; i<m; i++) scanf("%d %d", a+i, b+i);

	for(int i=m; i--; ){

		int x=Splay.remove(1);

		if(x && x!=a[i]) return puts("-1"), 0;

		Splay.insert(b[i], a[i]);

	}

	Splay.print(Splay.root);

	for(int i=0; i<n; i++){

		if(!p[i]) continue;

		if(vst[p[i]]) return puts("-1"), 0;

		vst[p[i]]=1;

	}

	int x=1;

	for(int i=0; i<n; i++){

		if(p[i]) continue;

		while(vst[x]) x++;

		p[i]=x, vst[x]=1;

	}

	for(int i=0; i<n; i++) printf("%d ", p[i]);

	return 0;

}

#include <iostream>

using namespace std;

void failure () {
  cout << -1 << endl;
  exit(0);
}

struct Cup {
  int key, init, mark;
};

bool operator< (Cup p, Cup q) {
  return p.key < q.key;
}

#include <bits/extc++.h>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>,
  rb_tree_tag, tree_order_statistics_node_update>;

// cur.order_of_key(2)
// the number of elements in the set less than 2
// *cur.find_by_order(1)
// the 1-st smallest number in the set(0-based)

const int MAX_N = 1e6 + 5;

ordered_set<Cup> row;

int seen [MAX_N];

// with mark x, at position y on time t (t is just for the keys)
// y should be 0-based
void op (int x, int y, int t) {
  Cup cur = *row.find_by_order(y);
  row.erase(cur);

  if (cur.mark != 0 && cur.mark != x) {
    failure();
  }

  if (cur.mark == 0 && seen[x]) {
    failure();
  }

  cur.mark = x;
  seen[x] = 1;
  cur.key = -t;
  row.insert(cur);
}

int ans [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    Cup cup;
    cup.key = i;
    cup.init = i;
    cup.mark = 0;
    row.insert(cup);
  }

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    y--;

    op(x, y, i);
  }

  set<int> unused;
  for (int i = 1; i <= n; i++) {
    if (!seen[i]) {
      unused.insert(i);
    }
  }

  for (Cup cup : row) {
    if (cup.mark == 0) {
      cup.mark = *unused.begin();
      unused.erase(cup.mark);
    }

    ans[cup.init] = cup.mark;
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
typedef long long LL;
#define N 1000505

struct Treap
{
    int nodecnt;
    int L[N] , R[N] , cnt[N];
    int key[N];
    void clear() {
        nodecnt = 0;
    }
    Treap () {clear();}
    bool hey(int A , int B) {
        return (LL)rand() * (cnt[A] + cnt[B]) < (LL)cnt[A] * RAND_MAX;
    }
    int newnode(int val) {
        nodecnt = val , L[nodecnt] = R[nodecnt] = 0;
        cnt[nodecnt] = 1 , key[nodecnt] = val;
        return nodecnt;
    }
    void pushup(int x) {
        cnt[x] = 1;
        if (L[x]) cnt[x] += cnt[L[x]] ;
        if (R[x]) cnt[x] += cnt[R[x]] ;
    }
    void merge(int& p , int x , int y) {
        if (!x || !y)
            p = x | y;
        else if ( hey(x , y) ) // key[x] < key[y]
            merge(R[x] , R[x] , y) , pushup(p = x);
        else
            merge(L[y] , x , L[y]) , pushup(p = y);
    }
    void split(int p , int& x , int& y , int size) {
        if (!size) {
            x = 0 , y = p;
            return;
        }
        if (cnt[L[p]] >= size)
            y = p , split(L[p] , x , L[y] , size) , pushup(y);
        else
            x = p , split(R[p] , R[x] , y , size - cnt[L[p]] - 1) , pushup(x);
    }
    void Build(int& p , int l , int r) {
        int mid = (l + r) >> 1;
        p = newnode(mid);
        if (l < mid) Build(L[p] , l , mid - 1);
        if (mid < r) Build(R[p] , mid + 1 , r);
        pushup(p);
    }
};
Treap T;
int n , m , a[N];
int ans[N];
bool used[N];
void work()
{
    int i , j , k , x , y , z;
    int root = 0;
    scanf("%d%d",&n,&m);
    T.Build(root , 1 , n);
    for (i = 0 ; i < m ; ++ i) {
        scanf("%d%d",&j,&k); // a[k] = j;
        T.split(root , x , z , k);
        T.split(x , x , y , k - 1); // y -> a[k]
        if (ans[y] && ans[y] != j)
            break;
        if (!ans[y]) {
            if (used[j])
                break;
            used[j] = 1 , ans[y] = j;
        }
        T.merge(x , y , x);
        T.merge(root , x , z);
    }
    if (i < m) {
        puts("-1");
        return;
    }
    j = 1;
    for (i = 1 ; i <= n ; ++ i) {
        if (!ans[i]) {
            while (used[j])
                ++ j;
            used[j] = 1 , ans[i] = j;
        }
        printf("%d%c" , ans[i] , " \n"[i == n]);
    }

}

int main()
{
    work();
    return 0;
}

// default code for competitive programming
// ver 3.1415 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, e) for( int i = 0 ; i < (e) ; i++ )
#define ITER(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#define PB push_back
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
    freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

#ifdef AKAI
#define debug( ... ) fprintf( stderr , __VA_ARGS__ )
#else
#define debug( ... )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = -1e8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

void _R( int& x ) { scanf( "%d" , &x ); }
void _R( ll& x ) { scanf( "%" PRId64 , &x ); }
void _R( double& x ) { scanf( "%lf" , &x ); }
void _R( char* s ) { scanf( "%s" , s ); }

void R() {}

template< typename T1 , typename... T2 >
void R( T1& x , T2&... tail )
{
  _R( x );
  R( tail... );
}

template< typename Iter , typename F >
inline void out( Iter s , Iter e , F of )
{
  bool flag = 0;
  for( Iter it = s ; it != e ; it++ )
  {
    if( flag ) printf( " " );
    else flag = 1;
    of( *it );
  }
  puts( "" );
}

// }}}
// start ~~QAQ~~

const int MAXN = 1000010;

inline int myRnd()
{ return rand() * 0x100 + rand(); }

struct Node
{
  static Node mem[ MAXN * 4 ];
  Node *l , *r;
  int pri;
  int pos , x , sz;
  Node() {}
  Node( int i ) : l( NULL ) , r( NULL ) , pri( myRnd() )
  {
    pos = i;
    x = -1;
    sz = 1;
  }
} Node::mem[ MAXN * 4 ] , *ptr = Node::mem;

inline int sz( Node *a ) { return a ? a->sz : 0; }

inline void pull( Node *a )
{
  if( !a ) return ;
  a->sz = sz( a->l ) + 1 + sz( a->r );
}

Node* merge( Node *a , Node *b ) {
  if( !a || !b ) return a ? a : b;
  if( a->pri > b->pri ) {
    a->r = merge( a->r , b );
    pull( a );
    return a;
  }
  else {
    b->l = merge( a , b->l );
    pull( b );
    return b;
  }
}

void split( Node *t , int k , Node *&a , Node *&b ) {
  if( !t ) {
    a = b = NULL;
    return ;
  }
  if( sz( t->l ) + 1 <= k ) {
    a = t;
    split( t->r , k-1-sz(t->l) , a->r , b );
    pull( a );
  }
  else {
    b = t;
    split( t->l , k , a , b->l );
    pull( b );
  }
}

int n , m;
Node *root;

void err(){ puts("-1");exit(0); }

int pos[ MAXN ] , sop[ MAXN ];

int main()
{
  srand( 514514 );
  R( n , m );
  REP( i , 1 , n )
  {
    root = merge( root , new ( ptr++ ) Node( i ) );
  }
  FOR( i , m )
  {
    int x , y;
    R( x , y );
    //printf( "%d %d\n" , x , y );
    Node *tl , *tr;
    split( root , y-1 , tl , root );
    split( root , 1 , root , tr );
    if( root->x != -1 && root->x != x )
      err();

    root->x = x;
    if( pos[ x ] && pos[ x ] != root->pos )
      err();
    pos[ x ] = root->pos;
    sop[ pos[ x ] ] = x;
    root = merge( root , merge( tl , tr ) );
    //printf( "done %d %d\n" , x , y );
  }

  vector< int > okx , okp;
  REP( i , 1 , n )
    if( !pos[ i ] ) okx.push_back( i );
  REP( i , 1 , n )
    if( !sop[ i ] ) okp.push_back( i );

  //if( SZ( okx ) != SZ( okp ) ) err();

  //printf( "%d\n" , SZ( okx ) );
  //printf( "%d\n" , SZ( okp ) );
  //out( ALL( okx ) , [&](int x){printf("%d",x);} );
  //out( ALL( okp ) , [&](int x){printf("%d",x);} );

  FOR( i , SZ( okx ) )
  {
    pos[ okx[ i ] ] = okp[ i ];
    sop[ okp[ i ] ] = okx[ i ];
  }

  REP( i , 1 , n ) printf( "%d%c" , sop[ i ] , " \n"[ i == n ] );

}

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

#define Max(a,b) (((a)>(b))?(a):(b))
const int maxn=1000005;

template<typename T>
struct Myset {
    struct Node{
        int sz, hei;
        Node *son[2];
        T val;

        Node():sz(1), hei(1) { son[0]=son[1]=NULL; }
    } *root;

    Myset():root(NULL) {}

    int height(Node *&node) {
        return (NULL==node)?0:node->hei;
    }

    int size(Node *&node) {
        return (NULL==node)?0:node->sz;
    }

    void fix(Node *&node) {
        node->hei=Max(height(node->son[0]),
                    height(node->son[1]))+1;
        node->sz=size(node->son[0])+size(node->son[1])+1;
    }

    void rotate(Node *&node, int rodir) {
        Node *pivot=node->son[1-rodir];
        node->son[1-rodir]=pivot->son[rodir];
        pivot->son[rodir]=node;
        if (node==root) root=pivot;
        node=pivot;

        fix(node->son[rodir]);
        fix(node);
    }

    void balance(Node *&node) {
        int dif=height(node->son[1])-height(node->son[0]);
        if (dif<-1 || dif>1) {
            int rodir=(dif>0)?0:1, dir=1-rodir;
            if (height(node->son[dir]->son[1-dir])
                -height(node->son[dir]->son[dir])>1)
                rotate(node->son[dir], dir);
            rotate(node, rodir);
        }
    }

    void insert(T &val, Node *&node) {
        if (NULL==node) {
            node=new Node();
            node->val=val;
            return;
        }
        if (val<=node->val) insert(val, node->son[0]);
        else insert(val, node->son[1]);
        fix(node);
        balance(node);
    }

    void erase(T &val, Node *&node) {
        if (NULL==node) return;
        if (val==node->val) {
            if (NULL==node->son[0]) {
                if (root==node) root=node=node->son[1];
                else node=node->son[1];
                return;
            } else if (NULL==node->son[1]) {
                if (root==node) root=node=node->son[0];
                else node=node->son[0];
                return;
            } else if (NULL==node->son[0] && NULL==node->son[1]) {
                node=NULL;
                return;
            }

            Node *suc=node->son[1], *sucPa=node;
            while (NULL!=suc->son[0]) { sucPa=suc; suc=suc->son[0]; }
            swap(suc->val, node->val);
            // sucPa->son[0]=NULL;
            erase(val, node->son[1]);
        }
        else if (val<node->val) erase(val, node->son[0]);
        else erase(val, node->son[1]);
        fix(node);
        balance(node);
    }

    T valAt(int rnk, Node *&node) {
        if (rnk>size(node)) return T();
        if (rnk<=size(node->son[0])) return valAt(rnk, node->son[0]);
        else if (rnk==1+size(node->son[0])) return node->val;
        else return valAt(rnk-1-size(node->son[0]), node->son[1]);
    }

    void insert(T val) { insert(val, root); }
    void erase(T val) { erase(val, root); }
    T valAt(int rnk) { return valAt(rnk, root); }
};

Myset<int> pos;
Myset<pair<int,int> > rec;
int vis[maxn], ans[maxn];

int main() {
    // freopen("in.txt", "r", stdin);

    int n, m;
    scanf("%d%d", &n, &m);
    memset(vis, 0, sizeof(vis));
    memset(ans, -1, sizeof(ans));
    for (int i=1; i<=n; ++i) pos.insert(i);

    int sum=0;
    while (m--) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (!vis[x]) {
            if (y<=sum) { printf("-1\n"); return 0; }
            ans[pos.valAt(y-sum)]=x;
            rec.insert(make_pair(m,x));
            pos.erase(pos.valAt(y-sum));
            vis[x]=1;
            ++sum;
        } else {
            if (y>rec.size(rec.root) || rec.valAt(y).second!=x) {
                printf("-1\n"); return 0;
            }

            rec.erase(rec.valAt(y));
            rec.insert(make_pair(m,x));
        }
    }
    int j=1;
    for (int i=1; i<=n; ++i) {
        if (-1==ans[i]) {
            while (vis[j]) ++j;
            vis[j]=1;
            ans[i]=j;
        }
    }
    for (int i=1; i<=n; ++i) {
        if (i-1) printf(" ");
        printf("%d", ans[i]);
    }
    printf("\n");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctype.h>
#include <cassert>
#include <stack>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define left _left

template < typename T > T abs(T x)
{
	return x > 0 ? x : -x;
}

struct node;
int getSize(node *v);

struct node
{
	node *l, *r;
	int size, pr;
	int val, idx;

	node()
	{
		l = r = NULL;
		size = 1;
		pr = rand();
	}

	void update()
	{
		size = 1 + getSize(l) + getSize(r);
	}
};

typedef node* pnode;

int getSize(node *v)
{
	return (v == NULL) ? 0 : v->size;
}

pnode merge(pnode l, pnode r)
{
	if (!l || !r)
	{
		return !l ? r : l;
	}

	if (l->pr > r->pr)
	{
		l->r = merge(l->r, r);
		l->update();
		return l;
	}
	else
	{
		r->l = merge(l, r->l);
		r->update();
		return r;
	}
}

void split(pnode v, pnode &l, pnode &r, int key)
{
	if (!v)
	{
		l = r = NULL;
		return;
	}

	if (1 + getSize(v->l) <= key)
	{
		l = v;
		split(v->r, l->r, r, key - (1 + getSize(v->l)));
	}
	else
	{
		r = v;
		split(v->l, l, r->l, key);
	}

	if (l)
		l->update();
	if (r)
		r->update();
}

const int maxn = 1000005;
int used[maxn];
int ans[maxn];

void dfs(pnode v)
{
	if (v == NULL)
		return;

	ans[v->idx] = v->val;

	if (v->val != -1)
	{
		if (used[v->val])
		{
			cout << -1;
			exit(0);
		}
		used[v->val] = 1;
	}

	dfs(v->l);
	dfs(v->r);
}

int main()
{
	//freopen("a.in", "r", stdin);

	int n, m;
	scanf("%d %d", &n, &m);

	pnode root = NULL;

	for (int i = 0; i < n; i++)
	{
		pnode v = new node();
		v->val = -1;
		v->idx = i;
		root = merge(root, v);
	}

	for (int i = 0; i < m; i++)
	{
		int xi, yi;
		scanf("%d %d", &xi, &yi);

		pnode left, center, right;
		split(root, left, center, yi - 1);
		split(center, center, right, 1);

		if (center->val != -1 && center->val != xi)
		{
			cout << -1 << endl;
			return 0;
		}

		center->val = xi;

		root = merge(merge(center, left), right);
	}

	dfs(root);

	int p = 1;

	for (int i = 0; i < n; i++)
	{
		while (p < maxn && used[p]) p++;

		if (ans[i] == -1)
		{
			//cerr << i << endl;
			ans[i] = p;
			p++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (i)
			printf(" ");
		printf("%d", ans[i]);
	}

	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>

#define ll long long

#define mp make_pair

using namespace std;

const int INF = 2e9;
const int MOD = 998244353;

struct node {
	int x, y, size;
	node* left;
	node* right;
	node(int val) {
		x = val;
		y = rand();
		size = 1;
		left = nullptr;
		right = nullptr;
	}
};

node* main_root = nullptr;

int get_size(node* root) {
	return root ? root->size : 0;
}

void update(node* root) {
	if (!root) return;
	root->size = get_size(root->left) + get_size(root->right) + 1;
}

node* merge(node* root1, node* root2) {
	if (!root1) return root2;
	if (!root2) return root1;
	if (root1->y < root2->y) {
		root1->right = merge(root1->right, root2);
		update(root1);
		return root1;
	}
	root2->left = merge(root1, root2->left);
	update(root2);
	return root2;
}

pair<node*, node*> split(node* root, int k) {
	if (!root) return mp(nullptr, nullptr);
	if (k == 0) return mp(nullptr, root);
	if (k >= get_size(root)) return mp(root, nullptr);
	if (get_size(root->left) >= k) {
		auto p = split(root->left, k);
		root->left = p.second;
		update(root);
		return mp(p.first, root);
	}
	auto p = split(root->right, k - get_size(root->left) - 1);
	root->right = p.first;
	update(root);
	return mp(root, p.second);
}
vector<bool> used;

bool add(int x, int y) {
	if (used[x] && y > get_size(main_root)) return false;
	if (!used[x]) {
		if (y <= get_size(main_root)) return false;
		node* new_node = new node(x);
		main_root = merge(new_node, main_root);
		used[x] = true;
		return true;
	}
	auto one = split(main_root, y - 1);
	auto two = split(one.second, 1);
	int q = two.first->x;
	main_root = merge(merge(two.first, one.first), two.second);
	return q == x;
}

void add2(int x, int y) {
	auto one = split(main_root, 1);
	auto two = split(one.second, y - 1);
	main_root = merge(merge(two.first, one.first), two.second);
}

void add(int x) {
	node* new_node = new node(x);
	main_root = merge(main_root, new_node);
}

void go(node* root) {
	if (!root) return;
	go(root->left);
	cout << root->x << " ";
	go(root->right);
}

void solve() {
	int n, m;
	cin >> n >> m;
	used.resize(n + 1);
	vector<vector<int>> ans(2, vector<int>(m));
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		ans[0][i] = x;
		ans[1][i] = y;
		if (!add(x, y)) {
			cout << -1;
			return;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!used[i]) add(i);
	}

	for (int i = m - 1; i >= 0;i--) {
		add2(ans[0][i], ans[1][i]);
	}

	go(main_root);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

#pragma comment(linker,"/STACK:102400000,102400000")
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<fstream>
#include<cmath>
#include<iomanip>
using namespace std;
//#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#define ll long long
#define ull unsigned long long
#define inf 2000000007
//#define mod 1000000007
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define N 1000010
#define pi 3.14159265358979323846
#define DBG(vari) cerr<<#vari<<"="<<(vari)<<endl;
#define FOREACH(i,t) for(typeof(t.begin()) i=t.begin();i!=t.end();i++)

int n,m,f[N<<1],sz,id[N<<1],p[N],use[N],x[N],y[N];
void add(int x,int v)
{
    while(x<=sz)f[x]+=v,x+=x&-x;
}
int find(int w)
{
    if(w==0)return 0;
    int x=0;
    for(int i=21;i>=0;i--)
    {
        int y=x+(1<<i);
        if(y<=sz&&f[y]<w)w-=f[y],x=y;
    }
    return x+1;
}
bool solve()
{
    sz=n+m+1;int i,k;
    for(i=0;i<=sz;i++)f[i]=0;
    memset(p,-1,sizeof(p));
    memset(id,-1,sizeof(id));
    for(i=1;i<=n;i++)add(m+i,1),id[m+i]=i,use[i]=0;
    for(i=0;i<m;i++)
    {
        int pos=find(y[i]);
        int j=id[pos];
        if(p[j]==-1)p[j]=x[i];
        if(p[j]!=x[i])return 0;
        add(pos,-1);
        add(m-i,1);
        id[pos]=-1;id[m-i]=j;
    }
    for(i=1;i<=n;i++)
    if(p[i]+1)
    {
        if(use[p[i]])return 0;
        else use[p[i]]=1;
    }
    for(k=1,i=1;i<=n;i++)
    if(p[i]==-1)
    {
        while(use[k])k++;
        p[i]=k;use[k]=1;
    }
    return 1;
}
int main()
{
    int T,i,j,k,ca=0;
    while(~scanf("%d%d",&n,&m))
    {
        for(i=0;i<m;i++)scanf("%d%d",&x[i],&y[i]);
        if(solve())
        {
            for(i=1;i<=n;i++)printf("%d ",p[i]);
            puts("");
        }
        else puts("-1");
    }
    return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DFOR(i,a,b) for(int i=a;i>=b;i--)
#define mp(x,y) make_pair((int)x,(int)y)
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define BUG(x) {cout << #x << " = " << x << endl;}
#define PR(x,a,b) {cout << #x << " = "; FOR(i,a,b) cout << x[i] << ' '; cout << endl;}
#define ll long long
#define DEBUG 0
#define nmax 1000111
int n,m;
int x[nmax],y[nmax];

void readInput(){
    scanf("%d%d",&n,&m);
    FOR(i,1,m) scanf("%d%d",x+i,y+i);
    if (DEBUG==1){
        BUG(n);
        BUG(m);
        PR(x,1,m);
        PR(y,1,m);
        cout<<"__________________________"<<endl;
    }
}

int s[nmax*2];
int smax;
void add(int id,int value){
    while (id<=smax){
        s[id]+=value;
        id=id+(id &(-id));
    }
}
int get(int id){
    int res=0;
    while (id>0){
        res+=s[id];
        id= id-(id &(-id));
    }
    return res;
}

int pos[nmax];
int pos_s[nmax];
int value_s[nmax*2];
bool ans;
void init(){
    smax=m+n;
    FOR(i,1,n) add(i,1);
    FOR(i,1,n) pos[i]=pos_s[i]=0;
    FOR(i,1,smax) value_s[i]=0;
    ans=true;
    if (DEBUG==1){
        BUG(smax);
        cout<<"____________________________"<<endl;
    }
}

int findPosition(int u){
    int l=1;
    int h=smax;
    while (l<h){
        int c= (l+h)/2;
        if (get(c)<u){
            l=c+1;
        }else
            h=c;
    }
    return h;
}
void querry(int value, int position,int stt){
    if (DEBUG==1){
        cout<<"__________________________"<<endl;
        BUG(value);
        BUG(position);
        BUG(stt);
        cout<<endl;
    }
    if (pos_s[value]>0){
        // dung de kiem tra dung sai
        int position_1= get(pos_s[value]);
        if (position_1!=position){
            ans=false;
            return;
        }
        add(pos_s[value],-1);
        add(n+stt,1);
        pos_s[value]=n+stt;
        value_s[n+stt]=value;
        if (DEBUG==1){
            PR(value_s,1,smax);
        }
        return;
    }
    int position_s= findPosition(position);
    if (value_s[position_s]!=0){
        ans=false;
        return ;
    }
    //cout<<"xxxx"<<endl;
    pos[value]=position_s;
    if (DEBUG==1){
        BUG(position_s);
    }
    value_s[position_s]=value;
    add(position_s,-1);
    position_s=n+stt;
    pos_s[value]=position_s;
    value_s[position_s]=value;
    add(position_s,1);
    if (DEBUG==1){
        PR(value_s,1,smax);
    }
}
void solve(){
    FOR(i,1,m) {
          querry(x[i],n-y[i]+1,i);
          if (ans==false) break;
    }
    if (ans){
        int j=n;
        FOR(i,1,n) if (pos[i]==0){
            while (j>0 && value_s[j]>0) j--;
            pos[i]=j;
            value_s[j]=i;
        }
    }
}

void writeOutput(){
    if (ans){
        DFOR(i,n,1) {
            printf("%d",value_s[i]);
            if (i>1) printf(" ");
        }
    }else {
        printf("-1");
    }

}
int main(){
    if (DEBUG==1){
        freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
    }
    readInput();
    init();
    solve();
    writeOutput();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N = 1000006;
int n, q, nw = 1, A[N], M[N];
struct Node
{
    int id = 0, p = 0, sz = 0;
    Node * l = NULL, * r = NULL;
};
int Size(Node * T)
{
    return (T ? T->sz : 0);
}
void Split(Node * T, Node * &L, Node * &R, int i)
{
    if (!T)
        L = R = NULL;
    else if (Size(T->l) + 1 <= i)
        Split(T->r, T->r, R, i - Size(T->l) - 1), L = T;
    else
        Split(T->l, L, T->l, i), R = T;
    if (T) T->sz = Size(T->l) + Size(T->r) + 1;
}
void Merge(Node * &T, Node * L, Node * R)
{
    if (!L) T = R;
    else if (!R) T = L;
    else if (L->p > R->p) Merge(L->r, L->r, R), T = L;
    else Merge(R->l, L, R->l), T = R;
    if (T) T->sz = Size(T->l) + Size(T->r) + 1;
}
int main()
{
    srand(time(0));
    Node * T = NULL;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++)
    {
        Node * X = new Node;
        X->id = i + 1;
        X->p = rand();
        X->sz = 1;
        Merge(T, T, X);
    }
    for (; q; q --)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        Node * X, * Y;
        Split(T, X, T, b);
        Split(X, X, Y, b - 1);
        if (A[Y->id] && A[Y->id] != a)
            return !printf("-1");
        if (!A[Y->id] && M[a])
            return !printf("-1");
        A[Y->id] = a; M[a] = Y->id;
        Merge(X, Y, X); Merge(T, X, T);
    }
    for (int i = 1; i <= n; i++)
    {
        if (!A[i])
        {
            while (M[nw])
                nw ++;
            A[i] = nw ++;
        }
        printf("%d ", A[i]);
    }
    return (0);
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;

#define TRACE(x...) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define PRINT(x...) TRACE(printf(x))

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define FU(i, a, b) for(decltype(a) i = (a); i < (b); ++i)
#define fu(i, n) FU(i, 0, n)

#define mset(c, v) memset(c, v, sizeof(c))
#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define SZ(c) int((c).size())

const int INF = 0x3F3F3F3F; const int NEGINF = 0xC0C0C0C0;
const double EPS = 1e-8;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef long long ll;

class BIT {
	private:
		vector<int> tree;
		int N;
	public:
		BIT(int _N){
			N = _N+1;
			tree.resize(N,0);
		}

		void update(int ind, int value){
			ind++;
			while(ind<N)
			{
				tree[ind] += value;
				ind += (ind & -ind);
			}
		}

		int get(int ind){
			int sum=0;
			while(ind > 0)
			{
				sum += tree[ind];
				ind -= (ind & -ind);
			}
			return sum;
		}

		int get(int ind1, int ind2)	{
			if (ind1>=ind2) return 0;
			return get(ind2) - get(ind1);
		}
};

int cmp(double x, double y = 0, double tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
char ans[10000000];
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	BIT bit(n+1), bit2(n+1);
	vi pos(n, -1), last(n, -1), used(n, -1), coun(n, -1);
	bool valid = true;
	int k = 0;
	fu(i, m) {
		int x, y;
		scanf("%d %d", &x, &y); x--; y--;
		if (pos[x] == -1) {
			if (y < k) {
				valid = false;
				break;
			}
			pos[x] = -1;
			int mi = 0;
			int ma = n;
			while (ma > mi) {
				int me = (ma + mi)/2;
				int z = me + k - bit.get(me);
				if (used[me] == -1 && z == y) {
					used[me] = x;
					pos[x] = me;
					bit.update(me, +1);
					break;
				} else if (z <= y) mi = me + 1;
				else ma = me;
			}
			if (pos[x] == -1) {
				valid = false;
				break;
			}
			k++;
		} else {
			if (y >= k) {
				valid = false;
				break;
			}
			int poss = i - last[x] - 1 - bit2.get(last[x], n+1) + coun[x];
			if (y != poss) {
				valid = false;
				break;
			}
			bit2.update(last[x], +1);
		}
		last[x] = i;
		coun[x] = bit2.get(last[x], n+1);
	}
	if (!valid) printf("-1\n");
	else {
		int cur = 0;
		int posi = 0;
		fu(i, n) {
			if (i) ans[posi++] = ' ';
			if (used[i] != -1) posi += sprintf(ans + posi, "%d", used[i]+1);
			else {
				while (pos[cur] != -1) cur++;
				posi += sprintf(ans + posi, "%d", cur+1);
				cur++;
			}
		}
		ans[posi] = '\0';
		printf("%s\n", ans);
	}
	return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define M 2000010
using namespace std;
vector< pair<int, int> > vec[M];
#define ls p<<1
#define rs p<<1|1
#define MP make_pair
#define X first
#define Y second

struct Node
{
	int l, r;
	int cnt, col;
}nde[M<<2];
int xx[M], yy[M];
int n, m;
int pos[M];

void up( int p )
{
	nde[p].cnt = nde[ls].cnt + nde[rs].cnt;
}
void build( int l, int r, int p )
{
	nde[p].l = l, nde[p].r = r;
	nde[p].col = 0;
	if( l >= r ){
		nde[p].cnt = l > m;
		return;
	}
	int m = ( l + r ) >> 1;
	build( l, m, ls );
	build( m+1, r, rs );
	up( p );
}
int find( int p, int k )
{
	if( nde[p].l >= nde[p].r ) return p;
	if( nde[ls].cnt >= k ) return find( ls, k );
	else return find( rs, k - nde[ls].cnt );
}
void update( int k, int p, int flag, int num )
{
	if( nde[p].l >= nde[p].r ){
		nde[p].col = flag;
		nde[p].cnt = num;
		return;
	}
	if( k <= nde[ls].r ) update( k, ls, flag, num );
	else update( k, rs, flag, num );
	up( p );
}
int vis[M];
int solve()
{
	build( 1, m+n, 1 );
	int x, y;
	int lft = m;
	for( int i = 1; i <= m; ++i ){
		x = xx[i], y = yy[i];
		if( x > n ) return 0;
		int p = find( 1, y );
		if( nde[p].col ){
			if( nde[p].col != x ) return 0;
			update( nde[p].l, 1, 0, 0 );
			update( lft--, 1, x, 1 );
		}
		else{
			if( pos[x] && pos[x] != nde[p].l ) return 0;
			pos[x] = nde[p].l;
			update( nde[p].l, 1, 0, 0 );
			update( lft--, 1, x, 1 );
		}
	}
	for( int i = 1; i <= n; ++i ) if( pos[i] )
		vis[pos[i]-m] = 1, pos[i] -= m;
	int k = 1;
	for( int i = 1; i <= n; ++i ) if( !pos[i] ){
		while( vis[k] ) ++k;
		pos[i]= k;
		vis[k] = 1;
	}
	for( int i = 1; i <= n; ++i ) vis[pos[i]] = i;
	for( int i = 1; i <= n; ++i ) printf( "%d ", vis[i] );
	return 1;
}
int main()
{
	scanf( "%d%d", &n, &m );
	for( int i = 1; i <= m; ++i ) scanf( "%d%d", xx+i, yy+i );
	if( !solve() ) puts( "-1" );
}

#include <bits/stdc++.h>
#define zero NULL
#define FF first
#define SS second
#define MOD 1000000007
#define rtt rbegin
#define pb push_back
#include <iostream>
#include <cstdio>
#define src pair<pair<ll,ll>,ll>
#include <cstring>
#include <vector>
#include <algorithm>
#define MOD 1000000007
#define upperlimit 1000001001
#define epsilon 1e-11
#define TEMP 10000001
#define nil 0
#define DEV 1e11
#define debug 1e3
#define PRIMESCHECK 11111111
using namespace std;
typedef long long ll;
unordered_map<ll,unordered_map<ll,src> > inpmt;
vector<ll> dcp;
 void SieveOfErat()   //prec of eratosthenes
{

    bool prime[1000001];
    memset(prime, true, sizeof(prime));

    for (long long vec=2; vec*vec<=1000000; vec++)
    {

        if (prime[vec] == true)
        {

            for (long long dd=vec*2; dd<=1000000; dd += vec)
                prime[dd] = false;
        }
    }
}
ll gcd(ll aa,ll id2)
{
    if(aa==0)
    {
        return id2;

    }
    else
    return gcd(aa%id2,id2);
}
struct vect
{   struct vect *foll;
    ll calc;
    struct vect *succ;

};
const int N= 1<<21;
int n, m;
int a[N],b[N],arr[N],ans[N],bit[N];

void up(int x,int k)
{
    for(;x<N; x += x & -x)
        bit[x]+=k;
}

int get(int x)
{
    int num=0,sum = 0;
    for(int i=20;i>=0;i--)
    {
        if(bit[num| (1<<i)] + sum < x)
        {
            num |= 1 << i;
            sum+=bit[num];
        }
    }
    return num+1;
}

void assign(int i,int x)
{
    if(ans[i] && ans[i] != x)
    {
        puts("-1");
        exit(0);
    }
    ans[i]=x;
}

 main()
{
    scanf("%d %d", &n, &m);
    for(int i=1;i<=n;i++)
    {
        up(i+m, 1);
        arr[i+m]=i;
    }
    int ptr=m;
    for(int i=1;i<=m;i++)
    {
        scanf("%d %d", a+i,b+i);//fast
        int x=get(b[i]);
        int k=arr[x];
        assign(k,a[i]);
        up(x,-1);
        up(ptr,+1);
        arr[x]=0;
        arr[ptr]=k;
        ptr--;
    }
    for(int i=1;i<=n;i++)
    {
        int x=get(i);
    }
    set<int>s;
    for(int i=1;i<=n;i++)
        s.insert(i);
  //  vector<int>vs;
    for(int i=1;i<=n;i++){
        if(ans[i])
        {
            if(s.find(ans[i])==s.end())
             {
                puts("-1");
                return 0;
            }
            s.erase(ans[i]);
        }
    }
        for(int i=1;i<=n;i++)
         {
            if(!ans[i])
             {
                ans[i]=*s.begin();
            s.erase(s.begin());
        }
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MAXN = 6e6 + 5;
int n, m, np, cnt, pos[MAXN], p[MAXN], seg[MAXN];
bool mark[MAXN];

void add(int ind, int id = 1, int b = 1, int e = np + 1){
	if( b + 1 == e){
		seg[id] = 1;
		return;
	}
	int mid = (b + e)/2;
	if( ind < mid) add(ind, id*2, b, mid);
	else add(ind, id*2 + 1, mid, e);
	seg[id] = seg[id*2] + seg[id*2 + 1];

	return;
}

int get(int val, int id = 1, int b = 1, int e = np + 1){
	if( b + 1 == e) return b;
	int mid = (b + e)/2;
	int ans;
	if( mid - b - seg[id*2] >= val)  ans = get(val, id*2, b, mid);
	else ans = get(val - (mid - b - seg[id*2]), id*2 + 1, mid, e);
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    cnt = n, np = n + m;
    for (int i = 1; i <= n; i++) p[i] = i;
	while( m ){
		m --;
        int x, y;
        cin >> x >> y;
		y  = n + 1 - y;
        int ind = get(y);
        if( pos[p[ind]] != 0 && pos[p[ind]] != x) return cout << -1, 0;
        if( pos[p[ind]] == 0 && mark[x]) return cout << -1, 0;
        cnt ++, p[cnt] = p[ind], pos[p[ind]] = x, mark[x] = true;
		p[ind] = 0;
        add(ind);
    }
	cnt = 1;
	for(int i = n; i >= 1; i --){
		if( pos[i] == 0){
			while( mark[cnt]) cnt ++;
			pos[i] = cnt, cnt ++;
		}
	}
	for(int i = n; i >= 1; i --)
		cout << pos[i] << " ";

	return 0;
}

#pragma GCC optimize("no-stack-protector,Ofast")
#include<bits/stdc++.h>
using namespace std;

unsigned int seed=880301;
int rnd(){
    return seed=(seed*880301)^7122;
}

struct node{
    node *l,*r;
    int sz,val,pri;
    int lz(){return l?l->sz:0;}
    int rz(){return r?r->sz:0;}
    void psz(){sz=lz()+rz()+1;}
    node(int v=-1):l(0),r(0),sz(1),val(v),pri(rnd()){}
} *root,pool[1000006];

pair<int,int> op[1000006];
bitset<1000006> it;
int npt=1;

node *merge(node *a,node *b){
    if(!(a&&b))return a?:b;
    if(a->pri>b->pri){
        a->r=merge(a->r,b);
        a->psz();
        return a;
    }
    else{
        b->l=merge(a,b->l);
        b->psz();
        return b;
    }
}
void split(node *now,int sz,node *&a,node *&b){
    if(!now){a=b=0; return;}
    if(now->lz()>=sz){
        b=now;
        split(now->l,sz,a,b->l);
        b->psz();
    }
    else{
        a=now;
        split(now->r,sz-1-now->lz(),a->r,b);
        a->psz();
    }
}
void gl(node *now){
    if(!now)return;
    gl(now->l);
    if(now->val!=-1)printf("%d ",now->val);
    else{
        while(it[npt])++npt;
        printf("%d ",npt);
        it[npt]=1;
    }
    gl(now->r);
}

int inp(){
    char c; int x=0;
    while((c=getchar()) && (c<'0' || c>'9'));
    while((x=x*10+c-'0',c=getchar()) && c>='0' && c<='9');
    return x;
}

int main(){
    // ios_base::sync_with_stdio(0); cin.tie(0);
    int n=inp(),m=inp();
    for(int i=1;i<=m;++i){
        op[i].first=inp();
        op[i].second=inp();
        // it[op[i].first]=1;
    }
    for(int i=1;i<=n;++i)root=merge(root,&pool[i]);

    node *a,*b,*c,*d;
    for(int i=m;i>=1;--i){
        split(root,1,a,b);
        if(a->val==-1){
            if(it[op[i].first])exit((cout<<-1<<endl,0));
            a->val=op[i].first;
            it[op[i].first]=1;
        }
        else if(a->val!=op[i].first)exit((cout<<-1<<endl,0));
        split(b,op[i].second-1,c,d);
        root=merge(c,merge(a,d));
    }
    gl(root);
}
//hello//hellobig_tq//hello//hello

#pragma GCC optimize("no-stack-protector,Ofast")
#include<bits/stdc++.h>
using namespace std;

unsigned int seed=880301;
int rnd(){
    return seed=(seed*880301)^7122;
}

struct node{
    node *l,*r;
    int sz,val,pri;
    int lz(){return l?l->sz:0;}
    int rz(){return r?r->sz:0;}
    void psz(){sz=lz()+rz()+1;}
    node(int v=-1):l(0),r(0),sz(1),val(v),pri(rnd()){}
} *root,pool[1000006];

pair<int,int> op[1000006];
bitset<1000006> it;
int npt=1;

node *merge(node *a,node *b){
    if(!(a&&b))return a?:b;
    if(a->pri>b->pri){
        a->r=merge(a->r,b);
        a->psz();
        return a;
    }
    else{
        b->l=merge(a,b->l);
        b->psz();
        return b;
    }
}
void split(node *now,int sz,node *&a,node *&b){
    if(!now){a=b=0; return;}
    if(now->lz()>=sz){
        b=now;
        split(now->l,sz,a,b->l);
        b->psz();
    }
    else{
        a=now;
        split(now->r,sz-1-now->lz(),a->r,b);
        a->psz();
    }
}
void gl(node *now){
    if(!now)return;
    gl(now->l);
    if(now->val!=-1)printf("%d ",now->val);
    else{
        while(it[npt])++npt;
        printf("%d ",npt);
        it[npt]=1;
    }
    gl(now->r);
}

int inp(){
    char c; int x=0;
    while((c=getchar()) && (c<'0' || c>'9'));
    while((x=x*10+c-'0',c=getchar()) && c>='0' && c<='9');
    return x;
}

int main(){
    // ios_base::sync_with_stdio(0); cin.tie(0);
    int n=inp(),m=inp();
    for(int i=1;i<=m;++i){
        op[i].first=inp();
        op[i].second=inp();
        // it[op[i].first]=1;
    }
    for(int i=1;i<=n;++i)root=merge(root,&pool[i]);

    node *a,*b,*c,*d;
    for(int i=m;i>=1;--i){
        split(root,1,a,b);
        if(a->val==-1){
            if(it[op[i].first])exit((cout<<-1<<endl,0));
            a->val=op[i].first;
            it[op[i].first]=1;
        }
        else if(a->val!=op[i].first)exit((cout<<-1<<endl,0));
        split(b,op[i].second-1,c,d);
        root=merge(c,merge(a,d));
    }
    gl(root);
}
//hello//hellobig_tq

#include <bits/stdc++.h>
#define getchar gtx
#define size(t) (t ? t->sz : 0)
using namespace std;

const int maxn = 1e6 + 10;
int ans[maxn], x[maxn], y[maxn];
bool v[maxn];

inline int gtx() {
    const int N = 1048576;
    static char buffer[N];
    static char *p = buffer, *end = buffer;
    if (p == end) {
        if ((end = buffer + fread(buffer, 1, N, stdin)) == buffer) return EOF;
        p = buffer;
    }
    return *p++;
}

template <typename T>
inline bool rit(T& x) {
    char __c = 0; bool flag = false;
    while (__c = getchar(), (__c < '0' && __c != '-') || __c > '9') if (__c == -1) return false;
    __c == '-' ? (flag = true, x = 0) : (x = __c - '0');
    while (__c = getchar(), __c >= '0' && __c <= '9') x = x * 10 + __c - '0';
    if (flag) x = -x;
    return true;
}

template <typename T, typename ...Args>
inline bool rit(T& x, Args& ...args) { return rit(x) && rit(args...); }

struct treap {
    treap *lc, *rc;
    int val, pri, sz;
    treap(int v): val(v) {
        pri = rand();
        sz = 1;
        lc = rc = nullptr;
    }
    void pull() {
        sz = size(lc) + size(rc) + 1;
    }
};

treap *merge(treap* a, treap* b) {
    if (!a || !b) return a ? a : b;
    if (a->pri > b->pri) {
        a->rc = merge(a->rc, b);
        a->pull();
        return a;
    } else {
        b->lc = merge(a, b->lc);
        b->pull();
        return b;
    }
}

void split(treap* t, int k, treap*& a, treap*& b) {
    if (!t) {
        a = b = nullptr;
        return;
    }
    if (size(t->lc) + 1 <= k) {
        a = t;
        split(t->rc, k - size(t->lc) - 1, a->rc, b);
        a->pull();
    } else {
        b = t;
        split(t->lc, k, a, b->lc);
        b->pull();
    }
}

void go(treap* t, int l, int r) {
    if (!t) return;
    go(t->lc, l, l + size(t->lc) - 1);
    go(t->rc, l + size(t->lc) + 1, r);
    ans[l + size(t->lc)] = t->val;
}

int main() {
    srand(time(nullptr));
    int n, m; rit(n, m);
    treap *t = nullptr;
    for (int i = 0; i < n; ++i) t = merge(t, new treap(-1));
    for (int i = 0; i < m; ++i) rit(x[i], y[i]);
    for (int i = m - 1; i >= 0; --i) {
        treap *a, *b, *c, *d;
        split(t, 1, a, b);
        if (a->val == -1) a->val = x[i];
        else if (a->val != -1 && a->val != x[i]) return 0 * puts("-1");
        split(b, y[i] - 1, c, d);
        t = merge(merge(c, a), d);
    }
    go(t, 1, n);
    for (int i = 1; i <= n; ++i) if (ans[i] != -1) {
        if (v[ans[i]]) return 0 * puts("-1");
        v[ans[i]] = true;
    }
    vector<int> vec;
    for (int i = 1; i <= n; ++i) if (!v[i]) vec.push_back(i);
    size_t ind = 0;
    for (int i = 1; i <= n; ++i) {
        if (ans[i] != -1) printf("%d ", ans[i]);
        else printf("%d ", vec[ind++]);
    }
    puts("");
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=1;i<=(n);++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
const int INF=2e9;
const int MAXN=2000005,mxBit=20;
int N=MAXN-1;
int bit[MAXN];
inline void update(int p,int val){
	while(p<MAXN){
		bit[p]+=val;p+=p&-p;
	}
}
inline int kth(int k){
	int res=0;
	for (int i=1<<mxBit;i;i>>=1) if (res+i<MAXN&&bit[res+i]<k) k-=bit[res+=i];
	return res+1;
}
int refer[MAXN];
bool seen[1000005];
int ans[1000005],que[1000005],ptr;
int n,m;
int main(){
	ios::sync_with_stdio(false);
	RII(n,m);
	for (int i=n;i;--i){
		refer[N]=i;update(N,1);--N;
	}
	REP(i,m){
		int x,y;
		RII(x,y);
		int id=kth(y),who=refer[id];
		if ((ans[who]&&x!=ans[who])||(!ans[who]&&seen[x])){
			cout<<-1<<endl;return 0;
		}
		seen[x]=1;
		update(id,-1);
		refer[id]=0;
		refer[N]=who;
		ans[who]=x;
		update(N,1);
		--N;
	}
	ptr=0;
	REP(i,n) if (!seen[i]) que[++ptr]=i;
	ptr=0;
	REP(i,n){
		if (!ans[i]) ans[i]=que[++ptr];
		printf("%d ",ans[i]);
	}
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=1;i<=(n);++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
const int INF=2e9;
const int MAXN=1000005;
int lc[MAXN],rc[MAXN],pri[MAXN],siz[MAXN],val[MAXN],key[MAXN];
int N,rt;
/*
inline void push(int v){
if (rev[v]){
swap(lc[v],rc[v]);
rev[lc[v]]^=1;rev[rc[v]]^=1;
rev[v]=0;
}
if (tag[v]){
if (lc[v]) tag[lc[v]]+=tag[v],mn[lc[v]]+=tag[v],val[lc[v]]+=tag[v];
if (rc[v]) tag[rc[v]]+=tag[v],mn[rc[v]]+=tag[v],val[rc[v]]+=tag[v];
tag[v]=0;
}
}
*/
inline void pull(int v){
siz[v]=siz[lc[v]]+siz[rc[v]]+1;
}
inline void split(int t,int k,int &tl,int &tr){
if (!t) tl=tr=0;
else{
//push(t);
if (siz[lc[t]]+1<=k){
tl=t;split(rc[t],k-siz[lc[t]]-1,rc[t],tr);pull(tl);
}
else{
tr=t;split(lc[t],k,tl,lc[tr]);pull(tr);
}
}
}
inline int merge(int tl,int tr){
if (!tr) return tl;
else if (!tl) return tr;
if (pri[tl]>pri[tr]){
rc[tl]=merge(rc[tl],tr);pull(tl);return tl;
}
else{
lc[tr]=merge(tl,lc[tr]);pull(tr);return tr;
}
}
inline int newnode(int x){
++N;
key[N]=x;
pri[N]=rand();
siz[N]=1;
return N;
}
int n,m;
bool seen[MAXN];
int que[MAXN],ptr,cur;
int ans[MAXN];
int main(){
ios::sync_with_stdio(false);
srand(19260817);
N=rt=0;
RII(n,m);
REP(i,n) rt=merge(rt,newnode(i));
int tl,tr;
REP(i,m){
int x,y;RII(x,y);
split(rt,y-1,tl,rt);
split(rt,1,rt,tr);
if ((val[rt]&&val[rt]!=x)||(!val[rt]&&seen[x])){
cout<<-1<<endl;return 0;
}
val[rt]=x;
seen[x]=1;
rt=merge(rt,merge(tl,tr));
}
ptr=0;
REP(i,n) if(!seen[i]) que[++ptr]=i;
REP(i,n) if (val[i]) ans[key[i]]=val[i];
REP(i,n){
if (!ans[i]) ans[i]=que[++cur];
printf("%d ",ans[i]);
}
return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=1;i<=(n);++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
const int INF=2e9;
const int MAXN=1000005;

int lc[MAXN],rc[MAXN],pri[MAXN],siz[MAXN],val[MAXN],key[MAXN];
int N,rt;
/*
inline void push(int v){
	if (rev[v]){
		swap(lc[v],rc[v]);
		rev[lc[v]]^=1;rev[rc[v]]^=1;
		rev[v]=0;
	}
	if (tag[v]){
		if (lc[v]) tag[lc[v]]+=tag[v],mn[lc[v]]+=tag[v],val[lc[v]]+=tag[v];
		if (rc[v]) tag[rc[v]]+=tag[v],mn[rc[v]]+=tag[v],val[rc[v]]+=tag[v];
		tag[v]=0;
	}
}
*/
inline void pull(int v){
	siz[v]=siz[lc[v]]+siz[rc[v]]+1;
}
inline void split(int t,int k,int &tl,int &tr){
	if (!t) tl=tr=0;
	else{
		//push(t);
		if (siz[lc[t]]+1<=k){
			tl=t;split(rc[t],k-siz[lc[t]]-1,rc[t],tr);pull(tl);
		}
		else{
			tr=t;split(lc[t],k,tl,lc[tr]);pull(tr);
		}
	}

}
inline int merge(int tl,int tr){
	if (!tr) return tl;
	else if (!tl) return tr;
	if (pri[tl]>pri[tr]){
		rc[tl]=merge(rc[tl],tr);pull(tl);return tl;
	}
	else{
		lc[tr]=merge(tl,lc[tr]);pull(tr);return tr;
	}
}
inline int newnode(int x){
	++N;
	key[N]=x;
	pri[N]=rand();
	siz[N]=1;
	return N;
}
int n,m;
bool seen[MAXN];
int que[MAXN],ptr,cur;
int ans[MAXN];
int main(){
	ios::sync_with_stdio(false);
	srand(time(0));
	N=rt=0;
	RII(n,m);
	REP(i,n) rt=merge(rt,newnode(i));
	int tl,tr;
	REP(i,m){
		int x,y;RII(x,y);
		split(rt,y-1,tl,rt);
		split(rt,1,rt,tr);
		if ((val[rt]&&val[rt]!=x)||(!val[rt]&&seen[x])){
			cout<<-1<<endl;return 0;
		}
		val[rt]=x;
		seen[x]=1;
		rt=merge(rt,merge(tl,tr));
	}
	ptr=0;
	REP(i,n) if(!seen[i]) que[++ptr]=i;
	REP(i,n) if (val[i]) ans[key[i]]=val[i];
	REP(i,n){
		if (!ans[i]) ans[i]=que[++cur];
		printf("%d ",ans[i]);
	}
	return 0;
}

/*input
10 3

7 10

8 7

5 5

*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
const int N = 4e6 + 100;
int n, m;

int val[N], used[N], ans[N];

struct fenwick {
	int n, c[N];
	fenwick(int _n = N - 1):n(_n) {
		memset(c, 0, sizeof c);
	}
	void insert(int p) {
		if (p < 0) return ;
		for (; p <= n; ++c[p], p += p & -p);
	}
	int find_by_order(int k) {
		++k;
		int x = 0;
		for (int i = 21; 0 <= i; --i)
			if (x + (1 << i) <= n && c[x + (1 << i)] < k)
				x += 1 << i, k -= c[x];
		return x + 1;
	}
	void erase(int p) {
		for (; p <= n; --c[p], p += p & -p);
	}
} pos;

int32_t main() {
 	fast;

	cin>>n>>m;
	for (int i = m + 1; i <= n + m; ++i)
		pos.insert(i);
	for (int i = 1; i <= m; ++i) {
		int x, y;
		cin>>x>>y;
		ll p = pos.find_by_order(y - 1);
		ll t = p;
		pos.erase(p);
		if (!val[t]) {
			ans[t - m] = x;
			if (used[x]) return puts("-1"), 0;
			used[x] = true;
			val[m - i + 1] = x;
			t = m - i + 1;
		} else {
			if (val[t] != x) return puts("-1"), 0;
			val[m - i + 1] = val[t];
			t = m - i + 1;
		}
		pos.insert(t);
	}
	int t = 1;
	for (int i = 1; i <= n; ++i)
		if (!ans[i]) {
			while (used[t]) ++t;
			ans[i] = t++;
		}
	for (int i = 1; i <= n; ++i)
		cout<<ans[i]<<" ";
	cout<<endl;

	return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define f first
#define s second

using namespace std;

const int N = 2e6 + 10;
const int md = 1e9 + 7;

int n, m;

int a[N];

int x[N];
int y[N];

int used[N];
int pos[N];

int t[N * 4];

vector <int> v;

int get(int v, int tl, int tr, int l, int r) {
    if (tl > r || l > tr) return 0;
    if (l <= tl && tr <= r) return t[v];
    int tm = (tl + tr) / 2;
    return get(v + v, tl, tm, l, r) + get(v + v + 1, tm + 1, tr, l, r);
}

void upd (int v, int tl, int tr, int pos, int x) {
    if (tl == tr) t[v] = x;
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm) upd(v + v, tl, tm, pos, x);
        else upd(v + v + 1, tm + 1, tr, pos, x);
        t[v] = t[v + v] + t[v + v + 1];
    }
}

int get1(int v, int tl, int tr, int b) {
    if (tl == tr) return tl;
    int tm = (tl + tr) / 2;
    if (tm + 1 + t[v + v + 1] <= b) return get1(v + v + 1, tm + 1, tr, b);
    else return get1(v + v, tl, tm, b - t[v + v + 1]);
}

int main() {
    scanf("%d%d", &n, &m);
    int cur = m;
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &x[i], &y[i]);
        if (!used[x[i]]) {
            pos[x[i]] = get1(1, 1, n, y[i]) + m;
            a[pos[x[i]] - m] = x[i];
            upd(1, 1, n, pos[x[i]] - m, 1);
        }
        used[x[i]] = 1;
    }
    for (int i = 1; i <= n; i++) {
        if (!used[i]) v.pb(i);
    }
    int it = 0;
    for (int i = 1; i <= n; i++) {
        if (!a[i]) {
            if (it == int(v.size())) return cout << -1, 0;
            a[i] = v[it];
            pos[a[i]] = m + i;
            it++;
        }
    }
    for (int i = 0; i <= 2000000; i++) t[i] = 0;
    cur = m;
    for (int i = 1; i <= n; i++) {
        upd(1, 1, n + m, pos[i], 1);
    }
    for (int i = 1; i <= m; i++) {
        int sum = get(1, 1, n + m, 1, pos[x[i]]);
        if (sum != y[i]) return cout << -1, 0;
        upd(1, 1, n + m, pos[x[i]], 0);
        pos[x[i]] = cur;
        upd(1, 1, n + m, pos[x[i]], 1);
        cur--;
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << ' ';
    }
    return 0;
}

#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss
const int N = 1e6 + 10;
const long long INF = 1e9 + 19;

struct Node {
    Node *l, *r;
    int y, pos, cnt;
    Node() {
        y = rand();
        pos = -1;
        cnt = 1;
        l = NULL;
        r = NULL;
    }
};

int n, m;
Node data[N];
int curData = 0;
Node * empty;
int answer[N];
bool use[N];

Node * getNew() {
    curData++;
    return data + (curData - 1);
}

void upd(Node * v) {
    v->cnt = v->l->cnt + v->r->cnt + 1;
}

Node * merge(Node * l, Node * r) {
    assert(l != NULL && r != NULL);
    if (l == empty) return r;
    if (r == empty) return l;
    if (l->y > r->y) {
        l->r = merge(l->r, r);
        upd(l);
        return l;
    }
    else {
        r->l = merge(l, r->l);
        upd(r);
        return r;
    }
}

void split(Node * head, int cnt, Node * & l, Node * & r) {
    assert(head != NULL);
    if (head == empty) {
        l = r = empty;
        return;
    }
    if (head->l->cnt < cnt) {
        split(head->r, cnt - head->l->cnt - 1, head->r, r);
        upd(head);
        l = head;
    }
    else {
        split(head->l, cnt, l, head->l);
        upd(head);
        r = head;
    }
}

void read() {
    scanf("%d%d", &n, &m);
}

void solve() {
    empty = getNew();
    empty->cnt = 0;
    Node * head = empty;
    for (int i = 0; i < n; i++) {
        //db(i);
        Node * v = getNew();
        v->l = empty;
        v->r = empty;
        v->pos = i;
        head = merge(head, v);
    }
    //db("here");

    assert(head->cnt == n);
    memset(answer, -1, sizeof(answer));
    for (int i = 0; i < m; i++) {
        int x, y;
        scanf("%d%d", &x, &y); x--; y--;
        Node * l, * r, * mid;
        split(head, y, l, r);
        split(r, 1, mid, r);
        assert(mid->cnt == 1);
        if (answer[mid->pos] == -1) {
            if (use[x]) {
                puts("-1");
                return;
            }
            use[x] = 1;
            answer[mid->pos] = x;
        }
        else {
            if (answer[mid->pos] != x) {
                puts("-1");
                return;
            }
        }
        head = merge(mid, merge(l, r));
    }
    //for (int i = 0; i < n; i++)
        //if (answer[i] != -1)
            //use[answer[i]] = 1;
    vector < int > tmp;
    for (int i = 0; i < n; i++)
        if (!use[i])
            tmp.pb(i);
    int cur = 0;
    for (int i = 0; i < n; i++)
        if (answer[i] == -1)
            answer[i] = tmp[cur++];
    assert(cur == (int)tmp.size());
    for (int i = 0; i < n; i++)
        printf("%d ", answer[i] + 1);
    puts("");

}

void stress() {

}

int main(){
#ifdef DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}

// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )
#define ALL(x) begin(x),end(x)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
// }}}

#define N 1000010

vector<int> sol;

namespace treap {
    const int INF=0x7FFFFFFF;
    int my_rand() {
        static int seed;
        return seed=seed*1103515245+12345;
    }
    struct Treap {
        static Treap mem[N],*pmem;
        Treap *l,*r;
        int rnd,size,val;
        bool rev;
        Treap() {}
        Treap( int _val ):l(NULL),r(NULL),rnd(my_rand()),size(1),val(_val) {}
    } Treap::mem[N],*Treap::pmem=Treap::mem;
    inline int size( Treap *t ) { return t?t->size:0; }
    inline void pull( Treap *t ) {
        if ( !t ) return;
        t->size=size(t->l)+size(t->r)+1;
    }
    Treap* merge( Treap *a, Treap *b ) {
        if ( !a || !b ) return a?a:b;
        if ( a->rnd < b->rnd ) {
            a->r=merge(a->r,b);
            pull(a);
            return a;
        } else {
            b->l=merge(a,b->l);
            pull(b);
            return b;
        }
    }
    void split( Treap *t, int k, Treap *&a, Treap *&b ) {
        if ( !t ) a=b=NULL;
        else if ( k<=size(t->l) ) {
            b=t;
            split(t->l,k,a,b->l);
            pull(b);
        } else {
            a=t;
            split(t->r,k-size(t->l)-1,a->r,b);
            pull(a);
        }
    }
    void inorder( Treap *t ) {
        if ( t->l ) inorder(t->l);
        sol.PB(t->val);
        if ( t->r ) inorder(t->r);
    }
}

using namespace treap;

int n,m,x[N],y[N];
bool used[N];

int main() {
    RI(n,m);
    REP(i,m) RI(x[i],y[i]);
    Treap *t=NULL,*tl,*tr;
    REP(i,n) t=merge(t,new (Treap::pmem++) Treap(0));
    bool good=1;
    for ( int i=m-1; i>=0; i-- ) {
        split(t,1,tl,t);
        split(t,y[i]-1,t,tr);
        if ( tl->val ) good&=(tl->val==x[i]);
        else {
            good&=!used[x[i]];
            used[x[i]]=1;
            tl->val=x[i];
        }
        t=merge(t,merge(tl,tr));
    }
    if ( !good ) {
        puts("-1");
    } else {
        sol.reserve(n);
        inorder(t);
        int cur=1;
        for (auto &c : sol) if ( c==0 ) {
            while ( used[cur] ) cur++;
            used[cur]=1;
            c=cur;
        }
        REP(i,n) printf("%d%c",sol[i],i+1==n?'\n':' ');
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
using namespace std;

#define mp make_pair
#define pb push_back
#define snuke(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it ++)
typedef long long lld;
typedef pair<int,int> PII;
const int N = 1001000;

struct Node *nill;

struct Node {
        Node *ch[2];
        int sz,id,r;
}memo[N],*bat,*root;
inline int ran() { static int ranx = 12762854; return ranx += ranx<<2|1; }
inline bool lor(int a,int b) { return (lld)ran()*(a+b) <= (lld)a*(~0u); }
inline void newNode(Node *&o) {
        o = bat ++;
        o->ch[0] = o->ch[1] = nill;
        o->sz = 1;
        o->id = -1;
        o->r = ran();
}
void init() {
        bat = memo;
        newNode(nill); nill->sz = 0;
        root = nill;
}
inline void up(Node *o) {
        if (o==nill) return ;
        o->sz = o->ch[0]->sz + o->ch[1]->sz + 1;
}
void merge(Node *&o,Node *a,Node *b) {
        if (a==nill) {
                o = b;
        } else if (b==nill) {
                o = a;
        } else {
                if (a->r > b->r) {
                        o = a;
                        merge(o->ch[1],a->ch[1],b);
                } else {
                        o = b;
                        merge(o->ch[0],a,b->ch[0]);
                }
                up(o);
        }
}
void cut(Node *o,Node *&a,Node *&b,int num) {
        if (num==0) {
                a = nill;
                b = o;
        } else if (num==o->sz) {
                a = o;
                b = nill;
        } else {
                if (o->ch[0]->sz >= num) {
                        b = o;
                        cut(o->ch[0],a,b->ch[0],num);
                        up(b);
                } else {
                        a = o;
                        cut(o->ch[1],a->ch[1],b,num - o->ch[0]->sz - 1);
                        up(a);
                }
        }
}

bool used[N];
int x[N],y[N],n,m,p;
void build(Node *&o,int l,int r) {
        if (l>r) return ;
        newNode(o);
        int mid = l+r>>1;
        build(o->ch[0],l,mid-1);
        build(o->ch[1],mid+1,r);
        up(o);
}

bool work(int x,int y) {
        Node *a,*b,*c;
        cut(root,a,b,1);
        if (a->id!=-1 && a->id!=x) {
                return false;
        }
        if (a->id==-1 && used[x]) {
                return false;
        }
        a->id = x;
        used[x] = 1;
        cut(b,b,c,y-1);
        merge(b,b,a);
        merge(root,b,c);
        return true;
}
void show(Node *o) {
        if (o==nill) return ;
        show(o->ch[0]);
        if (o->id==-1) {
                while (p<=n && used[p]) p ++;
                o->id = p ++;
        }
        printf("%d ",o->id);
        show(o->ch[1]);
}
inline void read(int &x) {
        char c; bool sig = 0;
        for (c = getchar(); c<'0' || c>'9'; c = getchar()) if (c=='-') sig = 1;
        for (x = c-'0',c = getchar(); c>='0' && c<='9'; c = getchar()) x = x*10+c-'0';
        sig && (x=-x);
}
int main() {
        read(n); read(m);
        init();
        build(root,1,n);
        for (int i = 0; i < m; i ++) {
                read(x[i]); read(y[i]);
        }
        for (int i = m-1; i >= 0; i --) {
                if (!work(x[i],y[i])) {
                        puts("-1");
                        return 0;
                }
        }
        p = 1;
        show(root);
        puts("");
        return 0;
}

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
typedef long long ll ;
#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
using namespace std;
const int maxn = 2000*1000+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;
int vc[maxn] , seg[maxn * 4] , val[maxn * 4] , n , m  ,sz = 1 , f[maxn]  , pos[4*maxn] , mark[maxn];
bool b = true ;
set<int> s ;
int get(int l , int x , int lx , int rx )
{
	if(rx - lx == 1)
	{
		return x;
	}
	int mid = lx + rx >> 1 ;
	if( seg[x << 1] >= l )
	{
		//cout<<x << " left " << l << " " << seg[x << 1] << endl ;
		get(l , x << 1 , lx , mid ) ;
	}
	else
	{
		l -= seg[x << 1] ;
		//cout<<x << " right" << endl ;
		get(l , x << 1 | 1 , mid , rx ) ;
	}
}
int pdu(int l , int x , int lx , int rx )
{
	if(rx - lx == 1)
	{
		seg[x] = 0 ;
		val[x] = 0 ;
		int h = pos[x] ;
		pos[x] = 0 ;
		return h ;
	}
	int mid = lx + rx >> 1 ;
	seg[x] -= 1 ;
	if( seg[x << 1] >= l )
	{
		return pdu(l , x << 1 , lx , mid ) ;
	}
	else
	{
		l -= seg[x << 1] ;
		return pdu(l , x << 1 | 1 , mid , rx ) ;
	}
}
void upd(int l , int x , int lx , int rx , int p , int v)
{
	if(rx - lx == 1)
	{
		seg[x] = 1 ;
		pos[x] = p;
		val[x] = v;
		return ;
	}
	int mid = lx + rx >> 1;
	if(l < mid)
	{
		upd(l , x << 1 , lx ,mid , p , v) ;
	}
	else
	{
		upd(l , x << 1 | 1 , mid , rx , p  ,v ) ;
	}
	seg[x] = seg[x << 1] + seg[x << 1 | 1] ;
}

int main()
{
	migmig ;
	cin>>n>>m ;
	while(sz <= m + n) sz *= 2;
	for(int i = 1 ; i <= n ; i ++ )
	{
		s.insert(i) ;
		upd(m + i , 1 , 0 , sz , i , 0) ;
	}
	int x , y  , pt , post;
	for(int i = 1; i <= m ; i ++ )
	{
		cin>>x>>y ;
		pt = get(y , 1 , 0 , sz) ;
		//cout<<"pt = " << pt << " val = " << val[pt] << " pos = " << pos[pt] << endl ;
		if(val[pt] > 0 && val[pt] != x)
		{
			b= false ;
		}
		post = pdu(y , 1 , 0 , sz) ;
		upd(m - i + 1 , 1 , 0 , sz , post , x) ;
	}
	if(!b)
	{
		//cout<<"boom" << endl ;
		cout<<-1 ;
		return 0 ;
	}
	for(int i = 1 ; i<= n ; i ++ )
	{
		pt = get(i , 1 ,0 ,sz) ;
		//cout<<i<<" pt = " << pt << " val = " << val[pt] << " pos = " << pos[pt] << endl ;
		f[pos[pt]] = val[pt] ;

		if(val[pt] > 0)
		mark[val[pt]] ++ ;
		if(mark[val[pt]] > 1)
		{
			cout<<-1 ;
			return 0 ;
		}
		s.erase(val[pt]) ;
	}
	for(int i =1 ; i<= n ; i ++)
	{
		if(f[i] != 0)
		{
			cout<<f[i] << ' ' ;
		}
		else
		{
			cout<<*s.begin() << " " ;
			s.erase(s.begin()) ;
		}
	}
	cout<<endl ;
}

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 21);
const int OFFSET = (1 << 20);

int answer[MAXN];

struct segment_tree
{
	int sum[MAXN << 2];
	int value[MAXN << 2];

	void init(int l, int r, int idx)
	{
		if(l == r)
		{
			sum[idx] = 0;
			value[idx] = -1;
			return;
		}

		int mid = (l + r) >> 1;
		init(l, mid, 2 * idx + 1);
		init(mid + 1, r, 2 * idx + 2);

		sum[idx] = sum[2 * idx + 1] + sum[2 * idx + 2];
	}

	int get_kth(int k, int l, int r, int idx)
	{
		if(l == r) return value[idx];

		int mid = (l + r) >> 1, sum_l = sum[2 * idx + 1];
		if(k <= sum_l) return get_kth(k, l, mid, 2 * idx + 1);
		else return get_kth(k - sum_l, mid + 1, r, 2 * idx + 2);
	}

	int get_kth_pos(int k, int l, int r, int idx)
	{
		if(l == r) return l;

		int mid = (l + r) >> 1, sum_l = sum[2 * idx + 1];
		if(k <= sum_l) return get_kth_pos(k, l, mid, 2 * idx + 1);
		else return get_kth_pos(k - sum_l, mid + 1, r, 2 * idx + 2);
	}

	void set_kth(int k, int val, int l, int r, int idx)
	{
		if(l == r) { value[idx] = val; return; }

		int mid = (l + r) >> 1, sum_l = sum[2 * idx + 1];
		if(k <= sum_l) set_kth(k, val, l, mid, 2 * idx + 1);
		else set_kth(k - sum_l, val, mid + 1, r, 2 * idx + 2);
	}

	void add_value(int pos, int val, int l, int r, int idx)
	{
		if(l == r) { sum[idx] += val; return; }

		int mid = (l + r) >> 1;
		if(pos <= mid) add_value(pos, val, l, mid, 2 * idx + 1);
		else add_value(pos, val, mid + 1, r, 2 * idx + 2);

		sum[idx] = sum[2 * idx + 1] + sum[2 * idx + 2];
	}

	int n, beginning;

	void init(int _n)
	{
		n = _n;
		beginning = 0;
		init(0, n + OFFSET, 0);
		for(int i = 1; i <= n; i++)
			add_value(OFFSET + i, 1, 0, OFFSET + n, 0);
	}

	int get(int pos) { return get_kth(pos, 0, OFFSET + n, 0); }
	void update(int pos, int new_value) { set_kth(pos, new_value, 0, OFFSET + n, 0); }

	void rem(int pos)
	{
		int p = get_kth_pos(pos, 0, OFFSET + n, 0);
		add_value(p, -1, 0, OFFSET + n, 0);
	}

	void shift(int pos)
	{
		int value = get(pos);
		rem(pos);
		add_value(beginning + OFFSET, 1, 0, OFFSET + n, 0);
		update(1, value);
		beginning--;
	}

	void get_answer(int l, int r, int idx)
	{
		if(l == r)
		{
			if(l > OFFSET) answer[l - OFFSET] = value[idx];
			return;
		}

		int mid = (l + r) >> 1;
		get_answer(l, mid, 2 * idx + 1);
		get_answer(mid + 1, r, 2 * idx + 2);
	}
};

int n, m;

void read()
{
	cin >> n >> m;
}

bool used[MAXN];
segment_tree t;

void solve()
{
	t.init(n);

	while(m--)
	{
		int x, y;
		cin >> x >> y;

		int value_at_pos = t.get(y);

		if(value_at_pos != -1 && value_at_pos != x)
		{
			cout << -1 << endl;
			return;
		}

		if(value_at_pos == -1 && used[x])
		{
			cout << -1 << endl;
			return;
		}

		if(value_at_pos == -1)
			t.update(y, x);

		used[x] = 1;
		t.shift(y);
	}

	t.get_answer(0, OFFSET + n, 0);

	set<int> av;
	for(int i = 1; i <= n; i++) av.insert(i);
	for(int i = 1; i <= n; i++)
		if(answer[i] != -1)
			av.erase(answer[i]);

	for(int i = 1; i <= n; i++)
		if(answer[i] == -1)
		{
			answer[i] = *av.begin();
			av.erase(av.begin());
		}

	for(int i = 1; i <= n; i++)
		cout << answer[i] << " ";
	cout << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
using namespace std;

#define mp make_pair
#define pb push_back
#define snuke(it,x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it ++)
typedef long long lld;
typedef pair<int,int> PII;
const int N = 1001000;

struct Node *nill;

struct Node {
        Node *ch[2];
        int sz,id,r;
}memo[N],*bat,*root;
inline unsigned ran() { static unsigned ranx = 12762854; return ranx += ranx<<2|1; }
inline bool lor(int a,int b) { return (lld)(~1u)*a <= (lld)ran()*(a+b); }
inline void newNode(Node *&o) {
        o = bat ++;
        o->ch[0] = o->ch[1] = nill;
        o->sz = 1;
        o->id = -1;
        o->r = ran();
}
void init() {
        bat = memo;
        newNode(nill); nill->sz = 0;
        root = nill;
}
inline void up(Node *o) {
        if (o==nill) return ;
        o->sz = o->ch[0]->sz + o->ch[1]->sz + 1;
}
void merge(Node *&o,Node *a,Node *b) {
        if (a==nill) {
                o = b;
        } else if (b==nill) {
                o = a;
        } else {
                if (a->r > b->r) {
                        o = a;
                        merge(o->ch[1],a->ch[1],b);
                } else {
                        o = b;
                        merge(o->ch[0],a,b->ch[0]);
                }
                up(o);
        }
}
void cut(Node *o,Node *&a,Node *&b,int num) {
        if (num==0) {
                a = nill;
                b = o;
        } else if (num==o->sz) {
                a = o;
                b = nill;
        } else {
                if (o->ch[0]->sz >= num) {
                        b = o;
                        cut(o->ch[0],a,b->ch[0],num);
                        up(b);
                } else {
                        a = o;
                        cut(o->ch[1],a->ch[1],b,num - o->ch[0]->sz - 1);
                        up(a);
                }
        }
}

bool used[N];
int x[N],y[N],n,m,p;
void build(Node *&o,int l,int r) {
        if (l>r) return ;
        newNode(o);
        int mid = l+r>>1;
        build(o->ch[0],l,mid-1);
        build(o->ch[1],mid+1,r);
        up(o);
}

bool work(int x,int y) {
        Node *a,*b,*c;
        cut(root,a,b,1);
        if (a->id!=-1 && a->id!=x) {
                return false;
        }
        if (a->id==-1 && used[x]) {
                return false;
        }
        a->id = x;
        used[x] = 1;
        cut(b,b,c,y-1);
        merge(b,b,a);
        merge(root,b,c);
        return true;
}
void show(Node *o) {
        if (o==nill) return ;
        show(o->ch[0]);
        if (o->id==-1) {
                while (p<=n && used[p]) p ++;
                o->id = p ++;
        }
        printf("%d ",o->id);
        show(o->ch[1]);
}
inline void read(int &x) {
        char c; bool sig = 0;
        for (c = getchar(); c<'0' || c>'9'; c = getchar()) if (c=='-') sig = 1;
        for (x = c-'0',c = getchar(); c>='0' && c<='9'; c = getchar()) x = x*10+c-'0';
        sig && (x=-x);
}
int main() {
        read(n); read(m);
        init();
        build(root,1,n);
        for (int i = 0; i < m; i ++) {
                read(x[i]); read(y[i]);
        }
        for (int i = m-1; i >= 0; i --) {
                if (!work(x[i],y[i])) {
                        puts("-1");
                        return 0;
                }
        }
        p = 1;
        show(root);
        puts("");
        return 0;
}

#include<iostream>
#include<fstream>
#include<vector>
#include<cstdlib>
#include<cstdio>

using namespace std;

struct item {
    int y, size, key;
    item *l, *r;
    item (int y, int size, int key): y(y), size(size), key(key), l(NULL), r(NULL) {}
};
typedef item * pitem;

int n, m, i, a, b, j;
long long y;
vector<int> v, c, d;
pitem t, u;

int size (pitem t){
    return t ? t->size:0;
}

void resize (pitem t){
    if (t)
        t->size=size(t->l)+size(t->r)+1;
}

void split (pitem t, int key, pitem &l, pitem &r){
    if (!t) return void (l=r=0);
     int keyp=size (t->l)+1;
     if (key <= keyp){
        split (t->l, key, l, t->l), r=t;
     }
     else {
        split (t->r, key, t->r, r), l=t;
     }
    resize(t);
}

void merge (pitem &t, pitem l, pitem r){
    if (!l || !r) t=l ? l:r;
    else if (l->y > r->y){
        merge (l->r, l->r, r), t=l;
    }
    else{
        merge (r->l, l, r->l), t=r;
    }
    resize(t);
}

void erase (pitem &t, int key){
    int keyp=size(t->l)+1;
    if (key==keyp){
        merge (t, t->l, t->r);
    }
    else{
        if (keyp<key){
            erase (t->r, key-=(size(t->l)+1));
            resize(t);
        }
        else{
            erase (t->l, key);
            resize(t);
        }
    }
}

void insert (pitem & t, pitem it, int key){
    pitem l, r, t1;
    split (t, key, l, r);
    merge (t1, l, it);
    merge (t, t1, r);
}

pitem order_statistics (pitem t, int key){
    int s=size(t->l)+1;
    if (key==s){
        pitem u=new item (t->y, 1, t->key);
        return u;
    }
    else if (key>s)
        order_statistics (t->r, key-s);
    else order_statistics (t->l, key);
}

int main (){
   // ifstream cin("input.txt"); ofstream cout("output.txt");
    //freopen ("input.txt", "rt", stdin); freopen ("output.txt", "wt", stdout);
    //cin>>n>>m;
    scanf ("%d%d", &n, &m);

    v.resize(n+1);
    c.resize(n+1);
    srand(2);
    for (i=1; i<=n; i++){
        a=rand(); b=rand();
        y=a*b;
        u=new item (y, 1, i);
        insert (t, u, i);
    }

    for (i=0; i<m; i++){
        //cin>>a>>b;
        scanf ("%d%d", &a, &b);
        u=order_statistics (t, b);
        if ((v[u->key]!=a && v[u->key])||(c[a] && c[a]!=u->key)){
            cout<<-1;
            return 0;
        }
        else {
            v[u->key]=a;
            c[a]=u->key;
            erase(t, b);
            insert(t, u, 1);
        }
    }

    for (i=1; i<=n; i++){
        if (c[i]==0) d.push_back(i);
    }
    j=0;
    for (i=1; i<=n; i++){
        if (v[i]) //cout<<v[i]<<' ';
            printf ("%d%c", v[i], ' ');
        else{
            //cout<<d[j]<<' ';
            printf ("%d%c", d[j], ' ');
            j++;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for (int i=s;i<=t;i++)
#define pi acos(-1)
typedef long long LL;
typedef pair<int,int> PII;
#define repp(i,s,t) for (int i=s;i>=t;i--)
template<class T> T sqr(T x) {return x*x;}
#define debug(x) cerr<<#x"="<<(x)<<endl;
#define pb(x) push_back(x);
#define bit(x) 1 << i
#define ori(x) x-'a'
const int mar = 1000001;
int tree[mar],used[mar],now[mar],seg[mar * 8];
int place[mar], ans[mar];
int times[mar];
int n,x,y,m;
void insert(int k,int x)
{
	while (k <= m)
	{
		tree[k] += x;
		k += k & -k;
	}
}
int query(int k)
{
	int ret = 0;
	while (k)
	{
		ret += tree[k];
		k -= k & -k;
	}
	return ret;
}
void insert(int k,int l,int r,int x,int p)
{
	if (l == r)
	{
		seg[k] = p;
		return;
	}
	int mid = (l + r) >> 1;
	if (x <= mid) insert(k*2,l,mid,x,p);
	else insert(k*2+1,mid+1,r,x,p);
	seg[k] = seg[k*2] + seg[k*2+1];
}
int query(int k,int l,int r,int p)
{
//	cout << k << " " << l << " " << r << " " << p << endl;
	if (l == r) return l;
	int mid = (l + r) >> 1;
	if (seg[k*2] >= p) return query(k*2,l,mid,p);
	else return query(k*2+1,mid+1,r,p-seg[k*2]);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	rep(i,1,n)
	{
		insert(1,1,n,i,1);
		place[i] = -1;
		now[i] = -1;
	}
//	cout << query(1,1,n,10) << endl;
	int cnt = 0;
	rep(__i,1,m)
	{
		scanf("%d%d",&x,&y);
		if (y <= cnt && now[x] == -1)
		{
			puts("-1");
			return 0;
		}
		if (y <= cnt)
		{
			int xx = query(now[x]);
			if (cnt - xx + 1 != y)
			{
				puts("-1");
				return 0;
			}
			insert(now[x], -1);
			insert(__i, 1);
			now[x] = __i;
		}
		else
		{
			if (place[x] > 0)
			{
				puts("-1");
				return 0;
			}

			int xx = query(1,1,n,y - cnt);
			place[x] = xx;
			insert(1,1,n,xx,0);
//			cout << x << " " << place[x] << endl;
			insert(__i, 1);
			now[x] = __i;
			times[y]++;
			cnt++;
		}
	}
	rep(i,1,n) if (place[i] > 0) ans[place[i]] = i;
	int tem = 1;
	rep(i,1,n) if (ans[i] == 0)
	{
		while (place[tem] != -1) tem++;
		ans[i] = tem++;
	}
	rep(i,1,n) printf("%d ",ans[i]);
	puts("");
	fclose(stdin);
	return 0;
}

#include<cstdio>
#include<cstring>
const int N = 1000005;
int c[2][N];
int lowbit(int x)
{
    return x&(-x);
}
int getsum(int x,int t)
{
    int r=0;
    while(x>0)
    {
        r+=c[t][x];
        x-=lowbit(x);
    }
    return r;
}
void up(int x,int v,int t)
{
    while(x<N)
    {
        c[t][x]+=v;
        x+=lowbit(x);
    }
}
int ps[N],pre[N];
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        up(m+1-i,1,1);
        up(m+1-pre[a],-1,1);
        if(pre[a])
        {
            int v=getsum(m+1-pre[a],1);
            if(b!=v){puts("-1");return 0;}
            pre[a]=i;
            continue;
        }
        pre[a]=i;
        int low=0,high=n+1,mid,fg=0;
        while(low<high-1)
        {
            int mid=(low+high)/2;
            int v=getsum(n+1-mid,0)+mid;
            if(v<b)low=mid;
            else if(v>b)high=mid;
            else if(ps[mid])low=mid;
            else {fg=mid;break;}
        }
        if(!fg){puts("-1");return 0;}
        ps[fg]=a;
        up(n+1-fg,1,0);
    }
    int t=1;
    for(i=1;i<=n;i++)
    {
        if(!ps[i]){while(pre[t])t++;ps[i]=t;t++;}
        printf("%d ",ps[i]);
    }
    return 0;
}

#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e6 + 10;

int c[N+N], pos[N], val[N+N];
bool have[N];

inline int lowbit(int x) {
	return x&(-x);
}

int sum(int n) {
	int ret = 0;
	while (n > 0){
		ret += c[n];
		n = n - lowbit(n);
	}
	return ret;
}

void update(int x, int v){
	while (x < N+N) {
		c[x] += v;
		x += lowbit(x);
	}
}

int get_kth(int k,int l,int r) {
	int mid;
	while (l+1 < r){
		mid = (l + r) / 2;
		//cout << l << " " << r << " " << " "<<mid<<" "<<sum(mid) << endl;
		if (sum(mid) >= k) r = mid;
		else l = mid;
	}
	return r;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, m, x, y, score = 0;
	cin >> n >> m;
	bool f = true;

	for (int i = 1; i <= n; i++) {
		update(m + i, 1);
	}

	for (int t=0; t<m; t++) {
		scanf("%d %d", &x, &y);
		if (f == false) {
			continue;
		}

		if (have[x] == false) {
			have[x] = true;
			int already = sum(m);
			if (y <= already) {
				f = false;
				continue;
			}

			int pre = get_kth(y, m, n + m);
			//cout << "pre " << pre << endl;
			//val[pre] = 0;
			update(pre, -1);
			update(m - t, 1);
			//val[m - t] = x;
			pos[pre-m] = x;
		}

		else{
			int already = sum(m);
			if (y > already) {
				f = false;
				continue;
			}
			int pre = get_kth(y,0,m);
			//cout << " " << already << " " << pre << " " << endl;
			//val[pre] = 0;
			update(pre, -1);
			update(m - t, 1);
			//val[m - t] = x;
		}
		//for (int i = 1; i <= (n + m); i++) cout << sum(i) << " "; cout << endl;
	}

	//for (int i = 1; i <= n; i++) cout << pos[i] << " "; cout << endl;
	if (f == false) {
		puts("-1");
		return 0;
	}
	int now = 1;
	for (int i = 1; i <= n; i++){
		if (pos[i] == 0){
			while (have[now] == true) {
				now++;
			}
			printf("%d ", now);
			now++;
		}
		else printf("%d ", pos[i]);
	}
}

#include <bits/stdc++.h>

using namespace std;

const int N = 1000005;

int order[N], vis[N];

struct nd{
    int p, cnt, idx, label;
    nd *l, *r;
    nd(){}
    nd(int idx) : idx(idx), p((rand() << 15) + rand()), cnt(1), label(- 1), l(NULL), r(NULL){}
};

nd *root = NULL, n_nd[N]; int nd_cnt = 0;

int cnt(nd* t){return t ? t->cnt : 0;}
void upt(nd* t){if(!t) return; t->cnt = cnt(t->l) + 1 + cnt(t->r);}

nd* new_nd(int idx){
    nd* t = &n_nd[nd_cnt++];
    t->idx = idx;
    t->p = (rand() << 15) + rand();
    t->cnt = 1;
    t->label = - 1;
    t->l = t->r = NULL;
    return t;
}

void split(nd* t, nd* &l, nd* &r, int p){
    if(!t) l = r = NULL;
    else if(p <= cnt(t->l)) split(t->l, l, t->l, p), r = t;
    else split(t->r, t->r, r, p - cnt(t->l) - 1), l = t;
    upt(t);
}

void merge(nd* &t, nd* l, nd* r){
    if(!l || !r) t = l ? l : r;
    else if(l->p > r->p) merge(l->r, l->r, r), t = l;
    else merge(r->l, l, r->l), t = r;
    upt(t);
}

void ins(nd* &t, nd* nn, int p){
    if(!t) t = nn;
    else if(nn->p > t->p) split(t, nn->l, nn->r, p), t = nn;
    else if(p <= cnt(t->l)) ins(t->l, nn, p);
    else ins(t->r, nn, p - cnt(t->l) - 1);
    upt(t);
}

void del(nd* &t, int p){
    if(cnt(t->l) == p) merge(t, t->l, t->r);
    else if(p < cnt(t->l)) del(t->l, p);
    else del(t->r, p - cnt(t->l) - 1);
    upt(t);
}

nd* get_nd(nd* t, int p){
    if(cnt(t->l) == p) return t;
    else if(p < cnt(t->l)) return get_nd(t->l, p);
    else return get_nd(t->r, p - cnt(t->l) - 1);
}

void prt(nd* t){
    if(!t) return;
    prt(t->l);
    order[t->idx] = t->label;;
    prt(t->r);
}

void heapify(nd* t){
    if(!t) return;
    nd* max = t;
    if(t->l && t->l->p > t->p) max = t->l;
    if(t->r && t->r->p > t->p) max = t->r;
    if(max != t){
        swap(max->p, t->p);
        heapify(max);
    }
}

nd* build(int lo, int hi){
    if(lo > hi) return NULL;
    int mid = (lo + hi) >> 1;
    nd* t = new_nd(mid);
    t->l = build(lo, mid - 1);
    t->r = build(mid + 1, hi);
    heapify(t);
    return t;
}

void init(nd* &t, int add = 0){
    if(!t) return;
    init(t->l, add);
    init(t->r, add + cnt(t->l) + 1);
    upt(t);
    t->idx = add + cnt(t->l);

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(NULL));
    int n, m, x, y; cin >> n >> m;
    root = build(0, n - 1);
    init(root);
    while(m--){
        cin >> x >> y;
        y--; x--;
        nd* t = get_nd(root, y);
        del(root, y);
        if((t->label == - 1 && vis[x]) || (t->label != - 1 && t->label != x)){
            cout << - 1 << "\n";
            return 0;
        }
        vis[x] = true;
        t->label = x;
        t->l = t->r = NULL;
        t->cnt = 1;
        ins(root, t, 0);
    }
    prt(root);
    int idx = 0;
    for(int i = 0; i < n; i++){
        if(order[i] != - 1) cout << order[i] + 1 << " ";
        else{
            while(vis[idx]) idx++;
            cout << idx + 1 << " ";
            idx++;
        }
    }
    cout << "\n";
}

//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &x){return scanf("%d",&x)==1;}bool SR(ll &x){return scanf("%lld",&x)==1;}
bool SR(double &x){return scanf("%lf",&x)==1;}bool SR(char *s){return scanf("%s",s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &x,T&... tail){return SR(x) && RI(tail...);}
//output
void SP(const int x){printf("%d",x);}void SP(const ll x){printf("%lld",x);}
void SP(const double x){printf("%.16lf",x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I x,const T... tail)
{SP(x);if(sizeof...(tail)) putchar(' ');PL(tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename I>
void _DOING(const char *s,I&& x){cerr<<s<<"="<<x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *s,I&& x,T&&... tail)//with ','
{
    int c=0;
    static const char bra[]="({[";
    static const char ket[]=")}]";
    while(*s!=',' || c!=0)//eg. mkp(a,b)
    {
        if(strchr(bra,*s)) c++;
        if(strchr(ket,*s)) c--;
        cerr<<*s++;
    }
    cerr<<"="<<x<<", ";
    _DOING(s+1,tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0);
template<typename It>
ostream& _OUTC(ostream &s,It b,It e)//container
{
    s<<"{";
    for(auto it=b;it!=e;it++) s<<(it==b?"":" ")<<*it;
    s<<"}";
    return s;
}
template<typename A,typename B>
ostream& operator <<(ostream&s, const pair<A,B> &p){return s<<"("<<p.F<<","<<p.S<<")";}
template<typename A,typename B>
ostream& operator <<(ostream&s, const map<A,B> &c){return _OUTC(s,ALL(c));}
template<typename T>
ostream& operator <<(ostream&s, const set<T> &c){return _OUTC(s,ALL(c));}
template<typename T>
ostream& operator <<(ostream&s, const vector<T> &c){return _OUTC(s,ALL(c));}
#else
#define debug(...)
#endif
//}}}
const int maxn=1e6+6;
int rr()
{
static int seed;
return seed=seed*1103515245+12345;
}
struct Treap
{
    int pri,val,size;
    Treap *l,*r;
    Treap(int _v):
        pri(rr()),val(_v),size(1),l(0),r(0){}
};
int size(Treap *t){return t?t->size:0;}
void pull(Treap *t){t->size=size(t->l)+1+size(t->r);}
Treap *merge(Treap *a,Treap *b)
{
    if(!a||!b) return a?a:b;
    else if(a->pri > b->pri)
    {
        a->r=merge(a->r,b);
        pull(a);return a;
    }
    else
    {
        b->l=merge(a,b->l);
        pull(b);return b;
    }
}
void split(Treap *t,int k,Treap *&a,Treap *&b)
{
    if(!t) a=b=NULL;
    else if(k-size(t->l)-1>=0)
    {
        a=t;
        split(t->r,k-size(t->l)-1,a->r,b);
        pull(a);
    }
    else
    {
        b=t;
        split(t->l,k,a,b->l);
        pull(b);
    }
}
int n,m;
int x[maxn],y[maxn];
void read()
{
    RI(n,m);
    REP1(i,1,m) RI(x[i],y[i]);
}
Treap *t,*tl,*tt,*tr;
void build()
{
    REP(i,n) t=merge(t,new Treap(0));
}
void print(Treap *o,bitset<maxn> &b,vector<int> &v)
{
    if(o->l) print(o->l,b,v);
    v.pb(o->val);b[o->val]=1;
    if(o->r) print(o->r,b,v);
}
void sol()
{
    bitset<maxn> b;
    for(int i=m;i>=1;i--)
    {
        split(t,1,tt,t);
        if(tt->val && tt->val!=x[i]){PL(-1);return;}
        if(!tt->val && b[x[i]]){PL(-1);return;}
        b[tt->val=x[i]]=1;
        split(t,y[i]-1,tl,tr);
        t=merge(tl,merge(tt,tr));
    }
    vector<int> v;
    print(t,b,v);
    int pt=1;
    for(auto &p:v) if(!p)
    {
        while(b[pt]) pt++;
        b[p=pt]=1;
    }
    REP(i,n) printf("%d%c",v[i]," \n"[i==n-1]);
}
int main()
{
    srand(time(0));
    read();
    build();
    sol();
    return 0;
}

#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const int N = 1100000;

int c[N+N], pos[N], val[N+N];
bool have[N];
inline int lowbit(int x){
	return x&(-x);
}

int sum(int n){
	int ret = 0;
	while (n > 0){
		ret += c[n];
		n = n - lowbit(n);
	}
	return ret;
}

void update(int x, int v){
	while (x <N+N){
		c[x] += v;
		x += lowbit(x);
	}
}

int get_kth(int k,int l,int r){
	int mid;
	while (l+1 < r){
		mid = (l + r) / 2;
		//cout << l << " " << r << " " << " "<<mid<<" "<<sum(mid) << endl;
		if (sum(mid) >= k) r = mid;
		else l = mid;
	}
	return r;
}
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int n, m, x, y, score = 0;
	cin >> n >> m;
	bool f = true;

	for (int i = 1; i <= n; i++) update(m + i, 1);

	for(int t=0;t<m;t++) {
		scanf("%d %d", &x, &y);
		if (f == false) {
			continue;
		}
		if (have[x] == false) {
			have[x] = true;
			int already = sum(m);
			if (y <= already) {
				f = false; continue;
			}

			int pre = get_kth(y, m, n + m);
			//cout << "pre " << pre << endl;
			val[pre] = 0;
			update(pre, -1);
			update(m - t, 1);
			val[m - t] = x;
			pos[pre-m] = x;
		}

		else{
			int already = sum(m);
			if (y > already) {
				f = false;
				continue;
			}
			int pre = get_kth(y,0,m);
			if (val[pre] != x) {
				f = false;
				continue;
			}
			//cout << " " << already << " " << pre << " " << endl;
			val[pre] = 0;
			update(pre, -1);
			update(m - t, 1);
			val[m - t] = x;
		}
		//for (int i = 1; i <= (n + m); i++) cout << sum(i) << " "; cout << endl;
	}

	//for (int i = 1; i <= n; i++) cout << pos[i] << " "; cout << endl;
	if (f == false) {
		puts("-1"); return 0;
	}
	int now = 1;
	for (int i = 1; i <= n; i++) {
		if (pos[i] == 0) {
			while (have[now] == true) now++;
			printf("%d ", now);
			now++;
		}
		else printf("%d ", pos[i]);
	}
}

	#include <bits/stdc++.h>
	using namespace std;

	struct node {
		int y, value, cnt, pos;

		node *l, *r;

		node(int value, int pos): value(value), l(nullptr), r(nullptr), y(rand() * rand()), cnt(1), pos(pos)
		{}

		~node() {
			if(l) delete(l);
			if(r) delete(r);
		}
	};

	int cnt(node*& t) {
		return t? t->cnt : 0;
	}

	void upd_cnt(node*& t) {
		if(!t) return;
		t->cnt = cnt(t->l) + cnt(t->r) + 1;
	}

	// x - ������� ��������� �� ����� ��������.
	pair<node*, node*> split(node*& t, int x) {

		if(!t) return {nullptr, nullptr};
		int cur_key = cnt(t->l);
		if(cur_key < x) {
			auto res = split(t->r, x - cur_key - 1);
			t->r = res.first;
			upd_cnt(t);
			return {t, res.second};
		} else {
			auto res = split(t->l, x);
			t->l = res.second;
			upd_cnt(t);
			return {res.first, t};
		}
	}

	node* merge(node* l, node* r) {
		if(!l || !r) return l? l : r;

		if(l->y > r->y) {
			l->r = merge(l->r, r);
			upd_cnt(l);
			return l;
		} else {
			r->l = merge(l, r->l);
			upd_cnt(r);
			return r;
		}
	}

	struct query {
		int val, idx;

	};

	query q[1000001];
	char used[1000001];
	int ans[1000001];

	void dfs(node* t) {
		if(!t) return;

		ans[t->pos] = t->value;
		dfs(t->l);
		dfs(t->r);
	}

	int main() {
		node* root = nullptr;
		int N, m;
		cin >> N >> m;
		for(int i = 0; i < m; i++) {
			scanf("%d%d", & q[i].val, &q[i].idx);
			q[i].idx--;
		}

		for(int i = 0; i < N; i++) {
			node* n = new node(0, i);
			root = merge(root, n);
		}

		for(int i = 0; i < m; i++) {
			auto res1 = split(root, q[i].idx);
			auto res2 = split(res1.second, 1);

			if(((res2.first)->value && (res2.first)->value != q[i].val)) {
				cout << -1;
				exit(0);
			}

			if(!(res2.first)->value && used[q[i].val]) {
				cout << -1;
				exit(0);
			}

			(res2.first)->value = q[i].val;
			used[q[i].val] = true;

			root = merge(res2.first, res1.first);
			root = merge(root, res2.second);
		}
		dfs(root);
		int cur = 1;
		for(int i = 0; i < N; i++) {
			if(!ans[i]) {
				while(used[cur]) cur++;
				ans[i] = cur++;
			}
			printf("%d ", ans[i]);
		}
	}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int N,M,Num;
int x,y,v;
int tree[8000005];
int que[2000005],Ans[1000005],cnt[1000005];
bool yes[1000005];

void add(int root,int le,int ri)
{
	if ((le>y) || (ri<x)) return;
	if ((le>=x) && (ri<=y))
	{
		tree[root]+=v;
		return;
	}
	int mid=(le+ri)/2;
	add(2*root,le,mid);
	add(2*root+1,mid+1,ri);
	tree[root]=tree[2*root]+tree[2*root+1];
}

int search(int root,int le,int ri)
{
	if (le==ri) return le;
	int mid=(le+ri)/2;
	int lson=2*root, rson=2*root+1;
	if (tree[lson]>=x) return search(lson,le,mid);
	else
	{
		x-=tree[lson];
		return search(rson,mid+1,ri);
	}
}

int main()
{
	scanf("%d%d",&N,&M);
	Num=N+M;
	for (int i=1; i<=N; i++)
	{
		x=y=M+i; v=1;
		add(1,1,Num);
	}
	for (int i=M+1; i<=M+N; i++) que[i]=i-M;
	int tail=M+1;
	memset(yes,false,sizeof(yes));
	bool flag=true;
	for (int i=1; i<=M; i++)
	{
		int xx,yy;
		scanf("%d%d",&xx,&yy);
		x=y=yy;
		int tmp=search(1,1,Num);
		x=y=tmp; v=-1;
		add(1,1,Num);
		if ((Ans[que[tmp]]!=0) && (Ans[que[tmp]]!=xx)) flag=false;
		if (Ans[que[tmp]]==0)
		{
			Ans[que[tmp]]=xx;
			cnt[xx]++;
			if (cnt[xx]>1) flag=false;
		}
		tail--;
		que[tail]=que[tmp];
		yes[xx]=true;
		x=y=tail; v=1;
		add(1,1,Num);
	}
	if (!flag)
	{
		printf("-1\n");
		return 0;
	}
	int j=1;
	for (int i=1; i<=N; i++)
		if (Ans[i]!=0) printf("%d ",Ans[i]);
	else
	{
		for (; yes[j]; j++);
		printf("%d ",j);
		j++;
	}
	return 0;
}

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>
#include <stack>
#include <cassert>
#include <string.h>

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define sqr(x) (x)*(x)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define X first
#define Y second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

const int maxn = 3000010;
int t[maxn];
int ind[maxn];
int res[maxn];
void inc(int r, int val) {
	for (;r < maxn; r |= (r+1)) t[r] += val;
}
int sum(int r) {
	int ans = 0;
	for (; r >= 0; r = (r&(r+1))-1) ans += t[r];
	return ans;
}
int sum(int l, int r) {
	return sum(r)-sum(l-1);
}

void doh() {
	printf("-1\n"), exit(0);
}

int u[maxn];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n, m; scanf("%d%d", &n, &m);
	int start = m+2;
	memset(res, -1, sizeof(res));
	forn(i, n) {
		inc(start+i,1);
		ind[start+i] = i;
	}
	forn(ii, m) {
		int xi, yi; scanf("%d%d", &xi, &yi);
		int l = start-1;
		int r = maxn;
		while (r-l>1) {
			int mid = (l+r)>>1;
			if (sum(start, mid) < yi) l = mid;
			else r = mid;
		}
		int pos = r;
		inc(pos, -1);
		--start;
		inc(start, 1);
		int num = ind[start] = ind[pos];
		if (res[num] == -1) {
			res[num] = xi;
		} else if (res[num] != xi) doh();
	}
	forn(i, n) if (res[i] >= 0) {
		u[res[i]]++;
		if (u[res[i]] > 1) doh();
	}
	int lst = 1;
	forn(i, n) {
		if (res[i] >= 0) continue;
		while (u[lst] == 1) ++lst;
		res[i] = lst++;
	}
	forn(i, n) printf("%d ", res[i]);
	return 0;
}

# include <bits/stdc++.h>

/*
// ordered_set
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

using namespace std;

typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;

# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

const int xn = 2e6 + 10;
const int xm = - 20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 1e9 + 7;
const int TM = 3;
const int base = 257;

int n, m, a[xn], ans[xn], seg[xn << 2], lazy[xn << 2], num[xn], p[xn];
deque <int> dq;

void shift(int id, int l, int r){
	if (!lazy[id]) return;
	seg[id] += lazy[id];
	if (r - l > 1){
		lazy[id << 1] += lazy[id];
		lazy[id << 1 | 1] += lazy[id];
	}
	lazy[id] = 0;
}
void update(int id, int l, int r, int ql, int qr, int val){
	shift(id, l, r);
	if (qr <= l || r <= ql) return;
	if (ql <= l && r <= qr){
		lazy[id] += val;
		shift(id, l, r);
		return;
	}
	int mid = l + r >> 1;
	update(id << 1, l, mid, ql, qr, val);
	update(id << 1 | 1, mid, r, ql, qr, val);
	seg[id] = max(seg[id << 1], seg[id << 1 | 1]);
}
int get(int id, int l, int r, int pos){
	//shift(id, l, r);
	if (r - l == 1) return l;
	int mid = l + r >> 1;
	shift(id << 1, l, mid);
	shift(id << 1 | 1, mid, r);
	if (pos <= seg[id << 1]) return get(id << 1, l, mid, pos);
	return get(id << 1 | 1, mid, r, pos);
}

int main(){
    InTheNameOfGod;

    cin >> n >> m;
    for (int i = m + 1; i <= n + m; ++ i){
    	a[i] = 1;
    	update(1, 1, n + m + 1, i, n + m + 1, 1);
	}
    for (int i = 1; i <= m; ++ i){
    	int x, y;
    	cin >> x >> y;
    	int ind = get(1, 1, n + m + 1, y);
		if (!p[x]) ans[ind - m] = x;
    	if (p[x] && p[x] != ind) kill(- 1);
    	if (num[ind] && num[ind] != x) kill(- 1);
		update(1, 1, n + m + 1, ind, n + m + 1, - 1);
		update(1, 1, n + m + 1, m - i + 1, n + m + 1, 1);
		a[ind] = num[ind] = 0;
		a[m - i + 1] = 1;
		num[m - i + 1] = x;
		p[x] = m - i + 1;
	}
	for (int i = 1; i <= n; ++ i) if (!p[i]) dq.push_back(i);
	for (int i = 1; i <= n; ++ i){
		if (ans[i]) continue;
		ans[i] = dq.front();
		dq.pop_front();
	}
	for (int i = 1; i <= n; ++ i) cout << ans[i] << sep;
	cout << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order_set;
order_set S;

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    cin>>n>>m;
    for (int i = 1; i <= n; i ++) S.insert(i);
    vector<int> p(n+1);
    vector<bool> vis(n+1);
    tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> pre;
    int tot = 0;
    while (m --) {
        int x, y;
        cin>>x>>y;
        if (y <= pre.size()) {
            pii cur = *pre.find_by_order(pre.size()-y);
            if (cur.second != x) {
                cout<<-1;
                return 0;
            }
            pre.erase(cur);
            tot ++;
            pre.insert(pii(tot, x));
        }
        else {
            int k = *S.find_by_order(y - pre.size() - 1);
            if (vis[x]) {
                cout<<-1;
                return 0;
            }
            p[k] = x;
            vis[x] = 1;
            tot ++;
            pre.insert(pii(tot, x));
            S.erase(k);
        }
    }
    int old = 1;
    for (int i = 1; i <= n; i ++) if (!p[i]) {
        p[i] = old;
        while (vis[p[i]]) p[i] ++;
        vis[p[i]] = 1;
        old = p[i];
    }
    for (int i =1 ; i <= n; i ++) cout<<p[i]<<' ';
}

#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

struct Treap
{
    int size, key, auxkey, val;
    Treap *lf, *rg;

    Treap(int _size, int _key, int _auxkey, int _val, Treap *_lf, Treap *_rg)
    {
        size = _size;
        key = _key;
        auxkey = _auxkey;
        val = _val;
        lf = _lf;
        rg = _rg;
    }
};
Treap *nil = new Treap(0, 0, 0, 0, 0, 0);
Treap *root = nil;

void get_size(Treap* &nod)
{
    if (nod == nil) return;
    nod->size = nod->lf->size + nod->rg->size + 1;
}
void rotate_lf(Treap* &nod)
{
    Treap* aux = nod->lf;
    nod->lf = nod->lf->rg;
    aux->rg = nod;
    nod = aux;

    get_size(nod->lf);
    get_size(nod->rg);
    get_size(nod);
}
void rotate_rg(Treap* &nod)
{
    Treap* aux = nod->rg;
    nod->rg = nod->rg->lf;
    aux->lf = nod;
    nod = aux;

    get_size(nod->lf);
    get_size(nod->rg);
    get_size(nod);
}
void balance(Treap* &nod)
{
    if (nod->lf->val > nod->val) rotate_lf(nod);
    if (nod->rg->val > nod->val) rotate_rg(nod);
    get_size(nod);
}
void insert(Treap* &nod, int key, int auxkey, int val)
{
    if (nod == nil)
    {
        nod = new Treap(1, key, auxkey, val, nil, nil);
        return;
    }

    if (nod->key > key) insert(nod->lf, key, auxkey, val);
    else                insert(nod->rg, key, auxkey, val);

    balance(nod);
}
void erase(Treap* &nod, int key)
{
    if (nod->key > key)
    {
        erase(nod->lf, key);
        balance(nod);
    }
    else if (nod->key < key)
    {
        erase(nod->rg, key);
        balance(nod);
    }
    else
    {
        if (nod->lf == nil && nod->rg == nil)
        {
            delete nod;
            nod = nil;
            return;
        }
        if (nod->lf->val > nod->rg->val)
        {
            rotate_lf(nod);
            erase(nod->rg, key);
            balance(nod);
        }
        else
        {
            rotate_rg(nod);
            erase(nod->lf, key);
            balance(nod);
        }
    }
}
int findt(Treap* &nod, int szn)
{
    if (nod->lf->size == szn) return nod->auxkey;

    if (nod->lf->size > szn) return findt(nod->lf, szn);
    else                     return findt(nod->rg, szn - nod->lf->size - 1);
}

int get_rand()
{
    int now = rand() * rand();
    if (now < 0) now = -now;
    if (now == 0) return 1;
    return now;
}

int N, M;
int A[1000002], F[1000002], W[1000002];
set<int> S;
bool impossible;

int main()
{
    srand(time(0));
    cin.sync_with_stdio(false);

    cin >> N >> M;

    for (int i = 1; i <= N; ++i)
    {
        insert(root, i, i, get_rand() + 1);
        W[i] = i;
    }
    for (int i = 1, what, where; i <= M; ++i)
    {
        cin >> what >> where;

        int pos = findt(root, where - 1);

        erase(root, W[pos]);
        W[pos] = --W[0];
        insert(root, W[pos], pos, get_rand() + 1);

        if (A[pos] == 0)
            A[pos] = what;
        else if (A[pos] != what)
            impossible = true;
    }

    for (int i = 1; i <= N; ++i)
        if (A[i] != 0)
        {
            if (F[A[i]] == 1) impossible = true;
            ++F[A[i]];
        }
    for (int i = 1; i <= N; ++i)
        if (F[i] == 0)
            S.insert(i);

    if (impossible)
        printf("-1\n");
    else
    {
        for (int i = 1; i <= N; ++i)
        {
            if (A[i] == 0)
            {
                A[i] = (*S.begin());
                S.erase(S.begin());
            }
            printf("%d ", A[i]);
        }
        printf("\n");
    }
}

#include <cstdio>
#define rep(i,s,e) for (int i=(s);i<=(e);++i)

const int N = 1<<20;
int t[2*N+1], n, m, lo, mid, p[N], R[N];

void upd(int i, int val) {
	for (; i <= 2*N; i += i & -i) t[i] += val;
}
int read(int i) {
	int s = 0;
	for (; i; i -= i & -i) s += t[i];
	return s;
}
int kth(int k) {
	int ans = 0, s = 0;
	for (int i = 21; i >= 0; --i)
		if (s + t[ans + (1<<i)] < k) {
			ans += 1<<i;
			s += t[ans];
		}
	return ans+1;
}

int main() {
	scanf("%d%d",&n,&m);
	lo = mid = m + 99;
	rep(i,mid+1,mid+n) upd(i, +1);
	rep(i,1,m) {
		int x, y; scanf("%d%d",&x,&y);
		if (!p[x]) {
			p[x] = kth(y);
			if (p[x] <= mid) { puts("-1"); return 0; }
			R[p[x] - mid] = x;
		}
		if (read(p[x]) != y) { puts("-1"); return 0; }
		upd(p[x], -1);
		upd(p[x]=lo--, 1);
	}
	int r = 1;
	rep(i,1,n) if (!p[i]) {
		while (R[r]) ++r;
		R[r] = i;
	}
	rep(i,1,n) printf("%d ",R[i]);
	puts("");
}

#include <bits/stdc++.h>
#include <cassert>
using namespace std;
typedef long long ll; typedef long double ld;
#define rep(i,s,e) for (int i=(s),__ee=(e);i<__ee;++i)
#define all(x) begin(x),end(x)
#define clr(x,y) memset(x,y,sizeof x)
#define contains(x,y) ((x).find(y)!=end(x))
#define pb push_back
#define Tu tuple
#define mk make_pair
#define mkt make_tuple
#define fst first
#define snd second
#define _1 get<0>
#define _2 get<1>
#define _3 get<2>
#define _4 get<3>
#define sz(x) ((int)(x).size())
#define tn typename
template <tn T> T read() { T x; cin >> x; return x; }
int dx[]={0,0,1,-1,1,-1,1,-1}, dy[]={-1,1,0,0,1,-1,-1,1};
void run();
int main() {
#ifdef LOCAL
#  define dbg(s, ...) printf(s "\n", __VA_ARGS__)
#else
#  define endl "\n"
#  define dbg(s,...)
#  define FILE "x"
	//freopen(FILE ".in", "r", stdin), freopen(FILE ".out", "w", stdout);
	ios::sync_with_stdio(0);
#endif
	cout << fixed << setprecision(16);
	run();
}

const int N = 1000200;
int tree[2*N+1];
int n, m, lo, mid;
int pos[N], init_pos[N], res[N];

// mode 1: update indices, read prefixes
void update_idx(int tree[], int i, int val) { // v[i] += val
	i++;
  for (; i <= 2*N; i += i & -i) tree[i] += val;
}
int read_prefix(int tree[], int i) { // get sum v[0..i]
	i++;
  int sum = 0;
  for (; i > 0; i -= i & -i) sum += tree[i];
  return sum;
}

void debug(int l, int r) {
	cout << "tree=";for(int i = l; i <= r; ++i)
		cout << read_prefix(tree,i)-read_prefix(tree,i-1) << " ";
	cout << endl;
}
int kth(int k) {
	int lo = 1, hi = mid + n;
	while (lo<hi) {
		int mid = (lo+hi)/2;
		if (read_prefix(tree, mid) >= k) hi = mid;
		else lo = mid + 1;
	}
	return lo;
}

bool solve() {
	cin >> n >> m;
	lo = mid = m + 100;
	for (int i = mid + 1; i <= mid + n; ++i) update_idx(tree, i, +1);
	rep(i,0,m) {
		int x, y; cin >> x >> y;
		//cout << "x y = " << x << " " << y << endl;
		if (!pos[x]) {
			pos[x] = kth(y);
			if (pos[x] <= mid) return 0;
			assert(pos[x] >= mid + 1);
			init_pos[x] = pos[x] - mid;
			//cout << "pos[x]=" << pos[x] << endl;
		}
		if (read_prefix(tree, pos[x]) != y) return 0;
		update_idx(tree, pos[x], -1);
		pos[x] = lo--;
		update_idx(tree, pos[x], 1);
		//for (int i = 1; i <= n; ++i) cout << "  pos[" << i << "]=" << pos[i] << endl;
		//debug(lo, mid + 4);
	}
	for (int i = 1; i <= n; ++i)
		if (init_pos[i]) res[init_pos[i]] = i;
	int p = 1;
	for (int i = 1; i <= n; ++i)
		if (!init_pos[i]) {
			while (res[p]) ++p;
			res[p] = i;
		}
	for (int i = 1; i <= n; ++i)
		cout << res[i] << " ";
	cout << endl;
	return 1;
}

void run() {
	if (!solve()) cout << -1 << endl;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define x first
#define y second
#define mp make_pair
using namespace std;
const int NMax=1100000;
inline int	read()
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; ch < '0' || ch > '9'; ch = getchar())	if (ch == '-')  positive = 0;
	for (; ch >= '0' && ch <= '9'; ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
struct node {
	int w,id,sz;
	node *left,*right;
	int lsize() {return left?left->sz:0;}
	int rsize() {return right?right->sz:0;}
}*T,pool[NMax];
typedef pair<node*,node*> pnn;
void update(node *p) {
	if(!p) return ;
	p->sz=p->lsize()+p->rsize()+1;
}
int L;
node *new_node(int id) {
	node *p=&pool[L++];
	p->w=rand();
	p->id=id;
	p->sz=1;
	p->left=p->right=NULL;
	return p;
}
node *new_node(int id,int w) {
	node *p=&pool[L++];
	p->w=w;
	p->id=id;
	p->sz=1;
	p->left=p->right=NULL;
	return p;
}
int N,M;
node *merge(node *a,node *b) {
	if(!a) return b;
	if(!b) return a;
	if(b->w>a->w) {
		a->right=merge(a->right,b);
		update(a);
		return a;
	}else {
		b->left=merge(a,b->left);
		update(b);
		return b;
	}
}
pnn split(node *a,int l) {
	if(!a) return mp((node*)NULL,(node*)NULL);
	if(l>=a->sz) return mp(a,(node*)NULL);
	if(l<=0) return mp((node*)NULL,a);
	if(l<=a->lsize()) {
		pnn ret=split(a->left,l);
		a->left=ret.y;
		update(a);
		ret.y=a;
		return ret;
	}else {
		pnn ret=split(a->right,l-a->lsize()-1);
		a->right=ret.x;
		update(a);
		ret.x=a;
		return ret;
	}
}
int have[NMax],chose[NMax],nn;
int oper[NMax];
void DFS(node *p) {
	if(p->left) DFS(p->left);
	if(p->id==-1) p->id=chose[nn++];
	if(p->right) DFS(p->right);
}
void DFS1(node *p) {
	if(p->left) DFS1(p->left);
	printf("%d ",p->id);
	if(p->right) DFS1(p->right);
}
node *Build(int x,int y,int w) {
	if(x==y) {
		node *p=new_node(-1,w);
		return p;
	}
	int mid=(x+y)>>1;
	node *p=new_node(-1,w);
	if(mid>x) p->left=Build(x,mid-1,w+rand());
	if(mid<y) p->right=Build(mid+1,y,w+rand());
	update(p);
	return p;
}
int main()
{
	N=read();M=read();
	T=Build(1,N,-100000000);
	for(int i=1;i<=M;i++) {
		int x,y;
		x=read();y=read();
		swap(x,y);
		oper[i]=x;
		pnn tmp=split(T,x-1);
		pnn tmq=split(tmp.y,1);
		if(have[y]&&tmq.x->id!=y) {
			puts("-1");
			getchar();getchar();
			return 0;
		}
		have[y]=1;
		if(tmq.x->id!=-1&&tmq.x->id!=y) {
			puts("-1");
			getchar();getchar();
			return 0;
		}
		tmq.x->id=y;
		tmp.x=merge(tmq.x,tmp.x);
		T=merge(tmp.x,tmq.y);
	}
	for(int i=1;i<=N;i++)
		if(!have[i]) chose[nn++]=i;
	nn=0;
	DFS(T);
	for(int i=M;i>=1;i--) {
		pnn tmp=split(T,oper[i]);
		pnn tmq=split(tmp.x,1);
		tmp.x=merge(tmq.y,tmq.x);
		T=merge(tmp.x,tmp.y);
	}
	DFS1(T);
	puts("");
	getchar();getchar();
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int NMax=1100000;
inline int	read()
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; ch < '0' || ch > '9'; ch = getchar())	if (ch == '-')  positive = 0;
	for (; ch >= '0' && ch <= '9'; ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
struct node {
	int w,id,sz;
	node *left,*right;
	int lsize() {return left?left->sz:0;}
	int rsize() {return right?right->sz:0;}
}*T,pool[NMax];
void update(node *p) {
	if(!p) return ;
	p->sz=p->lsize()+p->rsize()+1;
}
int L;
struct pnn {
	node *x,*y;
};
pnn mp(node *x,node *y) {
	pnn ret;
	ret.x=x;ret.y=y;
	return ret;
}
node *new_node(int id) {
	node *p=&pool[L++];
	p->w=rand()*rand();
	p->id=id;
	p->sz=1;
	p->left=p->right=NULL;
	return p;
}
node *new_node(int id,int w) {
	node *p=&pool[L++];
	p->w=w;
	p->id=id;
	p->sz=1;
	p->left=p->right=NULL;
	return p;
}
int N,M;
node *merge(node *a,node *b) {
	if(!a) return b;
	if(!b) return a;
	if(b->w>a->w) {
		a->right=merge(a->right,b);
		update(a);
		return a;
	}else {
		b->left=merge(a,b->left);
		update(b);
		return b;
	}
}
pnn split(node *a,int l) {
	if(!a) return mp((node*)NULL,(node*)NULL);
	if(l>=a->sz) return mp(a,(node*)NULL);
	if(l<=0) return mp((node*)NULL,a);
	if(l<=a->lsize()) {
		pnn ret=split(a->left,l);
		a->left=ret.y;
		update(a);
		ret.y=a;
		return ret;
	}else {
		pnn ret=split(a->right,l-a->lsize()-1);
		a->right=ret.x;
		update(a);
		ret.x=a;
		return ret;
	}
}
int have[NMax],chose[NMax],nn;
int oper[NMax];
void DFS(node *p) {
	if(p->left) DFS(p->left);
	if(p->id==-1) p->id=chose[nn++];
	if(p->right) DFS(p->right);
}
void DFS1(node *p) {
	if(p->left) DFS1(p->left);
	printf("%d ",p->id);
	if(p->right) DFS1(p->right);
}
node *Build(int x,int y,int w) {
	if(x==y) {
		node *p=new_node(-1,w);
		return p;
	}
	int mid=(x+y)>>1;
	node *p=new_node(-1,w);
	if(mid>x) p->left=Build(x,mid-1,w+rand());
	if(mid<y) p->right=Build(mid+1,y,w+rand());
	update(p);
	return p;
}
int main()
{
	N=read();M=read();
	T=Build(1,N,-100000000);
	for(int i=1;i<=M;i++) {
		int x,y;
		x=read();y=read();
		swap(x,y);
		oper[i]=x;
		pnn tmp=split(T,x-1);
		pnn tmq=split(tmp.y,1);
		if(have[y]&&tmq.x->id!=y) {
			puts("-1");
			getchar();getchar();
			return 0;
		}
		have[y]=1;
		if(tmq.x->id!=-1&&tmq.x->id!=y) {
			puts("-1");
			getchar();getchar();
			return 0;
		}
		tmq.x->id=y;
		tmp.x=merge(tmq.x,tmp.x);
		T=merge(tmp.x,tmq.y);
	}
	for(int i=1;i<=N;i++)
		if(!have[i]) chose[nn++]=i;
	nn=0;
	DFS(T);
	for(int i=M;i>=1;i--) {
		pnn tmp=split(T,oper[i]);
		pnn tmq=split(tmp.x,1);
		tmp.x=merge(tmq.y,tmq.x);
		T=merge(tmp.x,tmp.y);
	}
	DFS1(T);
	puts("");
	getchar();getchar();
	return 0;
}

#include <cstdio>
#include <cstdlib>

const int MAXN = 1001000;
const int MAXH = 20;

int H = 20;

int prand;
int bits = 0;
bool getb() {
  if (bits < 0) {
    prand = rand();
    bits = 31;
  }
  int ans = (prand >> bits) & 1;
  --bits;
  return ans;
}

int geth() {
  int ans = 0;
  while (ans + 1 < H && getb()) ++ans;
  return ans;
}

int nxt[MAXN][MAXH];
int len[MAXN][MAXH]; // #skipped + 1
int ans[MAXN];

int head = 1;

void ins(int nd, int pos) {
  int ht = geth();
  int cur = head;
  for(int h = H - 1; h >= 0; --h) {
    while (nxt[cur][h]) {
      if (len[cur][h] <= pos) {
        pos -= len[cur][h];
        cur = nxt[cur][h];
      } else {
        break;
      }
    }

//    printf("At %d %d\n", ans[cur], pos);
    if (h <= ht) {
      nxt[nd][h] = nxt[cur][h];
      len[nd][h] = len[cur][h] - pos;

      nxt[cur][h] = nd;
      len[cur][h] = pos + 1;
    } else {
      ++len[cur][h];
    }
  }
}

int pop() {
  int cur = head;
  int ans = nxt[cur][0];
  for(int h = H - 1; h >= 0; --h) {
    if (nxt[cur][h] && len[cur][h] == 1) {
      len[cur][h] = len[nxt[cur][h]][h];
      nxt[cur][h] = nxt[nxt[cur][h]][h];
    } else {
      --len[cur][h];
    }
  }
  return ans;
}

int X[MAXN], Y[MAXN];
int fin[MAXN];
bool vis[MAXN];

int N, M;
void disp() {
  int cur = head;
  for(int i = 0; i < N; ++i) {
    cur = nxt[cur][0];
    printf("%d ", ans[cur]);
  }
  printf("\n");
}

bool go() {
  scanf("%d %d", &N, &M);
  for(int i = 2; i <= N + 1; ++i) {
    ins(i, 0);
  }

  for(int i = 0; i < M; ++i) {
    scanf("%d %d", X + i, Y + i);
  }
  for(int i = M - 1; i >= 0; --i) {
    int x = X[i], y = Y[i];
    int front = pop();
    //printf("front = %d\n", front);
    //printf("ans[front] = %d\n", ans[front]);
    if (ans[front] && ans[front] != x) {
      return false;
    }
    ans[front] = x;
    ins(front, y - 1);
    //printf("inserting %d into %d\n", front, y - 1);
    //disp();
  }

  int cur = head;
  for(int i = 0; i < N; ++i) {
    cur = nxt[cur][0];
    fin[i] = cur;
  }
  for(int i = 0; i < N; ++i) {
    int a = ans[fin[i]];
    if (a) {
      if (vis[a]) return false;
      vis[a] = true;
    }
    //printf("ans[fin[%d]] = %d\n", i, ans[fin[i]]);
  }

  int n = 1;
  for(int i = 0; i < N; ++i) {
    if (!ans[fin[i]]) {
      while (vis[n]) ++n;
      ans[fin[i]] = n;
      ++n;
    }
    printf("%d ", ans[fin[i]]);
  }
  printf("\n");
  return true;
}

int main() {
  if (!go()) {
    printf("-1\n");
  }
  return 0;
}

#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<cmath>
#include<string>
#include<sstream>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<algorithm>
#pragma comment(linker, "/STACK:640000000")
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
using namespace std;
typedef pair<int, int> pii;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e6 + 10;
int x[maxn],y[maxn];
int t[8 * maxn];
int w[2 * maxn],f[2 * maxn];
bool was[maxn];
void update(int l, int r, int pos, int val, int idx) {
    if (l == r) {
        t[idx] += val;
    } else {
        int m = (l + r) >> 1;
        if (pos <= m) {
            update(l,m,pos,val,2 * idx);
        } else {
            update(m + 1,r,pos,val,2 * idx + 1);
        }
        t[idx] = t[2 * idx] + t[2 * idx + 1];
    }
}
int get(int l, int r, int val, int idx) {
    if (l == r) return l;
    int m = (l + r) >> 1;
    if (t[2 * idx] >= val) return get(l,m,val,2 * idx);
    return get(m + 1,r,val - t[2 * idx],2 * idx + 1);
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m; cin >> n >> m;
    memset(w,-1,sizeof(w));
    for (int i = 0; i < m; i++) {
        scanf("%d%d",&x[i],&y[i]);
    }
    for (int i = m; i < n + m; i++) {
        f[i] = i;
        update(0,n + m - 1,i,1,1);
    }
    for (int i = 0; i < m; i++) {
        int pos = get(0,n + m - 1,y[i],1);
        if ((was[x[i]] && w[pos] != x[i]) || (w[pos] != -1 && w[pos] != x[i])) {
            cout << -1 << endl;
            return 0;
        }
        update(0,n + m - 1,pos,-1,1);
        update(0,n + m - 1,m - i - 1,1,1);
        w[f[pos]] = x[i];
        f[m - i - 1] = f[pos];
        was[x[i]] = true;
        w[m - i - 1] = x[i];
    }
    int j = 1;
    for (int i = m; i < n + m; i++) {
        if (w[i] == -1) {
            while(was[j]) j++;
            printf("%d ",j);
            was[j] = true;
        } else {
            printf("%d ",w[i]);
        }
    }
    return 0;
}

#include <iostream>
#include <iostream>
#include <cstdio>
#include <cstring>

#define MAX 1000100
#define INF 1000000000
#define R (root->ch[1])
#define RL (root->ch[1]->ch[0])

using namespace std;

class Splay {
public:
    Splay() {
        root = nil = new Node();
        nil->ch[0] = nil->ch[1] = nil;
        nil->key = -1; nil->sz = 0;
        tot = top = idx = 0;
    }
    ~Splay() {}

    void init(const int *l, const int *r) {
        tot = top = 0;
        makeNode(root, INF, nil); makeNode(R, INF, root);
        makeTree(RL, l, 0, r - l - 1, R);
        pushUp(R); pushUp(root);
    }

    void clear() {
        root = nil;
        tot = top = 0;
    }

    void insert(int k, int val) {
        select(k, nil); select(k + 1, root);
        makeNode(RL, val, R);
        pushUp(R); pushUp(root);
    }

    void erase(int k) {
        select(k - 1, nil); select(k + 1, root);
        stk[++top] = RL; RL = nil;
        pushUp(R); pushUp(root);
    }

    bool empty() { return root == nil; }

    int size() { return root->sz; }

    int select(int k) {
        select(k, nil);
        return root->key;
    }

    int getItems(int *a) {
        idx = 0; getItems(a, root);
        return root->sz;
    }

private:
    struct Node {
        int key, sz;
        Node *ch[2], *pre;
    } v[MAX], *stk[MAX], *root, *nil;

    int tot, top, idx;

    void pushUp(Node *x) {
        x->sz = x->ch[0]->sz + x->ch[1]->sz + 1;
    }

    void pushDown(Node *x) {}

    void rotate(Node *x, int d) {
        Node *y = x->pre;
        pushDown(y); pushDown(x);
        if (y->ch[d ^ 1] = x->ch[d]) x->ch[d]->pre = y;
        if (x->pre = y->pre) y->pre->ch[y->pre->ch[1] == y] = x;
        x->ch[d] = y; y->pre = x; pushUp(y);
    }

    void splay(Node *x, const Node *p) {
        Node *y;
        int d;
        for (pushDown(x); (y = x->pre) != p; ) {
            if (y->pre == p) rotate(x, y->ch[0] == x);
            else {
                d = (y->pre->ch[0] == y);
                rotate(y->ch[d] == x ? x : y, d ^ (y->ch[d] == x));
                rotate(x, d);
            }
        }
        pushUp(x);
        if (p == nil) root = x;
    }

    void select(int k, const Node *p) {
        Node *x = root;
        int d;
        for (pushDown(x); x->ch[0]->sz != k; pushDown(x = x->ch[d])) {
            if (d = (x->ch[0]->sz < k)) k -= x->ch[0]->sz + 1;
        }
        splay(x, p);
    }

    void makeNode(Node *&x, int k, Node *p) {
        x = top ? stk[top--] : v + tot++;
        x->key = k; x->sz = 1;
        x->ch[0] = x->ch[1] = nil; x->pre = p;
    }

    void makeTree(Node *&x, const int *a, int l, int r, Node *p) {
        int mid = (l + r) >> 1;
        makeNode(x, a[mid], p);
        if (l < mid) makeTree(x->ch[0], a, l, mid - 1, x);
        if (mid < r) makeTree(x->ch[1], a, mid + 1, r, x);
        pushUp(x);
    }

    void getItems(int *a, Node *x) {
        if (x == nil) return;
        pushDown(x);
        getItems(a, x->ch[0]);
        a[idx++] = x->key;
        getItems(a, x->ch[1]);
    }
} spt;

int cur[MAX], pos[MAX], ans[MAX], x[MAX], y[MAX], num[MAX];

bool solve(int n, int m) {
    int u, cnt = 0, i, j;

    memset(ans, -1, sizeof(ans));
    memset(pos, -1, sizeof(pos));
    for (i = 1; i <= n; ++i) num[i] = i;
    spt.clear();
    spt.init(num + 1, num + n + 1);
    for (i = 0; i < m; ++i) {
        u = spt.select(y[i]);

        if (~pos[x[i]] && pos[x[i]] != u) return false;
        if (~ans[u] && ans[u] != x[i]) return false;
        pos[x[i]] = u; ans[u] = x[i];
        spt.erase(y[i]);
        spt.insert(0, u);
    }
    for (i = 1; i <= n; ++i) {
        if (pos[i] == -1) num[cnt++] = i;
        else ans[pos[i]] = i;
    }
    for (i = 1, j = 0; i <= n; ++i) {
        if (ans[i] == -1) ans[i] = num[j++];
    }

    return true;
}

int main() {
    int n, m, i;

    while (~scanf("%d%d", &n, &m)) {
        for (i = 0; i < m; ++i) scanf("%d%d", &x[i], &y[i]);
        if (!solve(n, m)) printf("-1\n");
        else {
            for (i = 1; i <= n; ++i) printf("%d%c", ans[i], i < n ? ' ' : '\n');
        }
    }

    return 0;
}

#include <iostream>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctime>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;

#define N 1001001

const int inf = 2 * 1000 * 1000 * 1000;

bool can[N];
int n, m, x, y;

template <typename T>
struct dich {
	struct item {
		item *l, *r;
		int prior, cnt;
		T key;
		item(T x, int y) {
			l = r = NULL;
			key = x;
			prior = y;
			cnt = 0;
		}
	};

	typedef item* pitem;

	dich() {
		t = NULL;
	}

	int cnt(pitem t) {
		return (t == NULL) ? 0 : t->cnt;
	}

	void upd_cnt(pitem t) {
		if (t != NULL) {
			t->cnt = cnt(t->l) + cnt(t->r) + 1;
		}
	}

	void split(pitem t, pitem &l, pitem &r, int key, int add = 0) {
		if (t == NULL) {
			l = r = NULL;
			return;
		}
		int cur_key = add + cnt(t->l);
		if (key <= cur_key) {
			split(t->l, l, t->l, key, add);
			r = t;
		} else {
			split(t->r, t->r, r, key, add + 1 + cnt(t->l));
			l = t;

		}
		upd_cnt(t);
	}

	void merge(pitem &t, pitem l, pitem r) {
		if (l == NULL) t = r; else
		if (r == NULL) t = l; else
		if (l->prior > r->prior) {
			merge(l->r, l->r, r);
			t = l;
		} else {
			merge(r->l, l, r->l);
			t = r;
		}
		upd_cnt(t);
	}

	void insert(int i, T x) {
		pitem t1 = NULL, t2 = NULL;
		split(t, t1, t2, i);
		merge(t1, t1, new item(x, rand()));
		merge(t, t1, t2);
	}

	void erase(int i) {
		pitem t1 = NULL, t2 = NULL, t3 = NULL;
		split(t, t1, t2, i);
		split(t2, t2, t3, 1);
		merge(t, t1, t3);
	}

	T get(int i) {
		pitem t1 = NULL, t2 = NULL, t3 = NULL;
		split(t, t1, t2, i);
		split(t2, t2, t3, 1);
		T ans = t2->key;
		merge(t2, t2, t3);
		merge(t, t1, t2);
		return ans;
	}

	void set(int i, T x) {
		pitem t1 = NULL, t2 = NULL, t3 = NULL;
		split(t, t1, t2, i);
		split(t2, t2, t3, 1);
		t2->key = x;
		merge(t2, t2, t3);
		merge(t, t1, t2);
	}

	bool to_front_and_set_and_check(int i, int x) {
		pitem t1 = NULL, t2 = NULL, t3 = NULL;
		split(t, t1, t2, i);
		split(t2, t2, t3, 1);
		if (t2->key.first != x && t2->key.first != 0) return false;
		if (t2->key.first == 0 && !can[x]) return false;
		t2->key.first = x;
		merge(t1, t2, t1);
		merge(t, t1, t3);
		return true;
	}

	void to_vector(pitem t, vector<int> &a) {
		if (t != NULL) {
			to_vector(t->l, a);
			a[t->key.second] = t->key.first;
			to_vector(t->r, a);
		}
	}

	void do_vector(vector<int> &a) {
		to_vector(t, a);
	}

	pitem t;
};

dich< pair<int, int> > a;

bool cmp1(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

int main() {
	ios::sync_with_stdio(0);
	//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		a.insert(i, make_pair(0, i));
		can[i] = true;
	}
	can[n] = true;

	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
		y--;
		if (!a.to_front_and_set_and_check(y, x)) {
			cout << -1;
			return 0;
		}
		can[x] = false;
	}

	vector< int > v(n);
	a.do_vector(v);

	int it = 1;
	while (can[it] != true) it++;
	for (int i = 0; i < v.size(); i++)
		if (v[i] == 0) {
			printf("%d ",it++);
			while (!can[it]) it++;
		} else printf("%d ", v[i]);
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

void perdi(){puts("-1");exit(0);}

typedef struct item *pitem;
struct item {
	int pr,cnt,val;
	pitem l,r;
	item(int val): pr(rand()),cnt(1),val(val),l(0),r(0){}
};
int cnt(pitem t){return t?t->cnt:0;}
void upd_cnt(pitem t){
	if(t){t->cnt=cnt(t->l)+cnt(t->r)+1;}
}
void merge(pitem& t, pitem l, pitem r){
	if(!l||!r)t=l?l:r;
	else if(l->pr>r->pr)merge(l->r,l->r,r),t=l;
	else merge(r->l,l,r->l),t=r;
	upd_cnt(t);
}
void split(pitem t, pitem& l, pitem& r, int sz){
	if(!t){l=r=0;return;}
	if(sz<=cnt(t->l))split(t->l,l,t->l,sz),r=t;
	else split(t->r,t->r,r,sz-1-cnt(t->l)),l=t;
	upd_cnt(t);
}

pitem s;
int r[1<<20];
int ri[1<<20];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n)merge(s,s,new item(i));
	memset(r,-1,sizeof(r));
	memset(ri,-1,sizeof(ri));
	while(m--){
		int x,y,k;
		scanf("%d%d",&x,&y);x--;y--;
		{
		pitem l,kk,r;
		split(s,l,s,y);
		split(s,kk,r,1);
		k=kk->val;
		merge(s,kk,l);merge(s,s,r);
		}
		if(r[k]>=0&&r[k]!=x)perdi();
		if(ri[x]>=0&&ri[x]!=k)perdi();
		r[k]=x;
		ri[x]=k;
	}
	int c=0;
	fore(i,0,n){
		if(i)putchar(' ');
		if(r[i]<0){
			while(ri[c]>=0)c++;
			r[i]=c++;
		}
		printf("%d",r[i]+1);
	}
	puts("");
	return 0;
}

#include<cstdio>
#include<cassert>
#include<vector>
#include<utility>
using namespace std;
unsigned int Rand()
{
	static unsigned int seed=20160220;
	seed*=0xdefaced,seed+=121546;
	return seed+=seed>>20;
}
struct Node
{
	Node *ch[2];
	const int val;
	unsigned int sz;
	Node(const int _val):ch{NULL,NULL},val(_val),sz(1){}
}*ROOT;
unsigned int Sz(Node *o){return o?o->sz:0;}
void Maintain(Node *o){o->sz=Sz(o->ch[0])+1+Sz(o->ch[1]);}
Node *Merge(Node *a,Node *b)
{
	if(!a||!b)return a?a:b;
	if(Rand()%(a->sz+b->sz)<(a->sz))
	{
		a->ch[1]=Merge(a->ch[1],b);
		Maintain(a);
		return a;
	}
	else
	{
		b->ch[0]=Merge(a,b->ch[0]);
		Maintain(b);
		return b;
	}
}
void Split(Node *o,Node* &a,Node* &b,const int loc)
{
	if(!o){a=b=NULL;return;}
	if(loc<=(int)Sz(o->ch[0]))
	{
		b=o;
		Split(b->ch[0],a,b->ch[0],loc);
		Maintain(b);
	}
	else
	{
		a=o;
		Split(a->ch[1],a->ch[1],b,loc-Sz(o->ch[0])-1);
		Maintain(a);
	}
}
void Extract(Node *o,vector<int>&output)
{
	if(!o)return;
	Extract(o->ch[0],output);
	output.push_back(o->val);
	Extract(o->ch[1],output);
}
int N,M;
bool Solve(const vector<pair<int,int> >&operations)
{
	static bool vis[1000001];
	for(int i=1;i<=N;i++)vis[i]=false;
	for(int i=M-1;i>=0;i--)
	{
		const pair<int,int>&p=operations[i];
		Node *begin;
		Split(ROOT,begin,ROOT,1);
		if((begin->val)!=0&&(begin->val)!=p.first)return false;
		if((begin->val)==0&&vis[p.first])return false;
		Node *a,*b;
		Split(ROOT,a,b,p.second-1);
		ROOT=Merge(a,Merge(new Node(p.first),b));
		vis[p.first]=true;
	}
	return true;
}
int main()
{
//	freopen("in.txt","r",stdin);
	while(scanf("%d%d",&N,&M)==2)
	{
		ROOT=NULL;
		for(int i=0;i<N;i++)ROOT=Merge(ROOT,new Node(0));
		vector<pair<int,int> >operations;
		for(int i=0,x,y;i<M;i++)scanf("%d%d",&x,&y),operations.push_back(make_pair(x,y));
		if(!Solve(operations))puts("-1");
		else
		{
			vector<int>ans;
			Extract(ROOT,ans);
			static int vis[1000001];
			for(int i=1;i<=N;i++)vis[i]=false;
			for(const int v:ans)vis[v]=true;
			vector<int>remain;
			for(int i=1;i<=N;i++)if(!vis[i])remain.push_back(i);
			for(int i=0,j=0;i<N;i++)if(ans[i]==0)assert(j<(int)remain.size()),ans[i]=remain[j++];
			for(int i=0;i<N;i++)
			{
				if(i)putchar(' ');
				printf("%d",ans[i]);
			}
			puts("");
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
#define fastio cin.tie(0); cin.sync_with_stdio(0);
#define MAXN 2000005

int N,M,arr[MAXN],idx[MAXN],st[4*MAXN],sz[4*MAXN],pp[MAXN];
bool done[MAXN];

int update(int pos, int val, int rt, int l = 1, int r = N+M){
    if(l == r){
        st[rt] = val, sz[rt] = !!val;
        return rt;
    }
    int mid = (l+r)/2, ret;
    if(pos <= mid) ret = update(pos,val,rt<<1,l,mid);
    else ret = update(pos,val,rt<<1|1,mid+1,r);
    sz[rt] = sz[rt<<1]+sz[rt<<1|1];
    return ret;
}

pii kth(int rt, int want, int l = 1, int r = N+M){
    if(l == r) return {st[rt],rt};
    int mid = (l+r)/2;
    if(sz[rt<<1] >= want) return kth(rt<<1,want,l,mid);
    return kth(rt<<1|1,want-sz[rt<<1],mid+1,r);
}

int get_order(int rt, int from_right){
    if(rt == 0) return 0;
    return get_order(rt/2,rt%2)+(from_right?sz[rt<<1]:0);
}

int main(){
    fastio; cin >> N >> M;
    for(int i=M+1; i<=N+M; i++)
        idx[i-M] = update(i,i-M,1), pp[i-M] = i;
//    s.print();
    int cur_lft = M+1;
    for(int i=1; i<=M; i++){
        int val,pos; cin >> val >> pos;
        pii real_pos = kth(1,pos);
        if(arr[real_pos.first] && arr[real_pos.first] != val){
            cout << -1 << endl;
            return 0;
        }
        if(done[val]){
            int should = get_order(idx[val],0)+1;
            if(should != pos){
//                should = s.get_order(nodes[val],0);
                cout << -1 << endl;
                return 0;
            }
        }
//        cout << real_pos << endl;
        update(pp[real_pos.first],0,1);
//        s.erase(s.rt,pos);
//        s.print();
//        idx[val] = --cur_lft;//new node<int>(real_pos);
        idx[val] = update(pp[real_pos.first]=--cur_lft,real_pos.first,1);
//        s.insert(nodes[val],1);
        arr[real_pos.first] = val;
        done[val] = true;
//        idx[val] = i;
//        s.print();
    }
    int ptr = 1;
    for(int i=1; i<=N; i++){
        if(arr[i]) cout << arr[i] << " ";
        else{
            while(done[ptr]) ptr++;
            done[ptr] = true;
            cout << ptr << " ";
        }
    }
}

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>

#if LOCAL
	#define DO_NOT_SEND
#endif

typedef long long LL;

int IntMaxVal = (int) 1e20;
int IntMinVal = (int) -1e20;
LL LongMaxVal = (LL) 1e20;
LL LongMinVal = (LL) -1e20;

#define FOR(i, a, b) for(int i = a; i < b ; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)

template<typename T> inline void minimize(T &a, T b) { a = std::min(a, b); }
template<typename T> inline void maximize(T &a, T b) { a = std::max(a, b); }

#define all(v) v.begin(),v.end()

using namespace std;

#define endl '\n'
template<typename T> struct argument_type;
template<typename T, typename U> struct argument_type<T(U)> { typedef U type; };
#define next(t, i) argument_type<void(t)>::type i; cin >> i;
#define nextVector(t, v, size) vector< argument_type<void(t)>::type > v(size); { for (int i = 0 ; i < size ; i++) cin >> v[i]; }

#define range(name, start, count) vector<int> name(count); { for (int i = 0 ; i < count ; i++) name[i] = i + start; }

template <typename T1, typename T2> istream& operator >>(istream& is, pair<T1, T2>& s) { is >> s.first >> s.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T> &v) { for (int i = 0 ; i < v.size() ; i++) os << v[i] << ' '; os << endl; return os; }
template <typename T1, typename T2> ostream& operator <<(ostream& s, pair<T1, T2>& t) { s << t.first << ' ' << t.second; return s; }
template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

const int UNKNOWN = -1;

#define TP Treap*

template <typename TData>
class Treap {
	public:

	int size;
	int lsize;
	int prior;

	TData data;

	Treap* left;
	Treap* right;

	void updateFromChildren() {
		lsize = 1;
		if (left != NULL) lsize += left->size;

		size = lsize;
		if (right != NULL) size += right->size;
	}

	Treap(int data, int prior, Treap* left, Treap* right) {
		this->data = data;
		this->prior = prior;
		this->left = left;
		this->right = right;

		updateFromChildren();
	}

	// splits tree into 2 parts, first contains n elements, second tree contains the rest
	static pair<Treap*, Treap*> split(Treap* root, int n) {
		if (root == NULL) return make_pair<Treap*,Treap*>(NULL, NULL);
		if (root->lsize == n) {
			Treap* right = root->right;
			root->right = NULL;
			root->updateFromChildren();
			return make_pair(root, right);
		} else if (root->lsize < n) {
			pair<Treap*, Treap*> splitted = split(root->right, n - root->lsize);
			root->right = splitted.first;
			root->updateFromChildren();
			return make_pair(root, splitted.second);
		} else {
			pair<Treap*, Treap*> splitted = split(root->left, n);
			root->left = splitted.second;
			root->updateFromChildren();
			return make_pair(splitted.first, root);
		}
	}

	static Treap* merge(Treap* t1, Treap* t2) {
		if (t1 == NULL) return t2;
		if (t2 == NULL) return t1;

		if (t1->prior > t2->prior) {
			t1->right = merge(t1->right, t2);
			t1->updateFromChildren();
			return t1;
		} else {
			t2->left = merge(t1, t2->left);
			t2->updateFromChildren();
			return t2;
		}
	}

	static Treap* insertAt(Treap* root, int index, TData data, int priority) {
		Treap* result;
		if (root == NULL) {
			result = new Treap(data, priority, NULL, NULL);
		} else if (priority > root->prior) {
			auto splitted = split(root, index);
			result = new Treap(data, priority, splitted.first, splitted.second);
		} else if (index < root->lsize) {
			root->left = insertAt(root->left, index, data, priority);
			result = root;
		} else {
			root->right = insertAt(root->right, index - root->lsize, data, priority);
			result = root;
		}
		result->updateFromChildren();
		return result;
	}

	static Treap* push_back(Treap* root, TData data, int priority) {
		if (root == NULL) {
			return new Treap(data, priority, NULL, NULL);
		} else return Treap::insertAt(root, root->size, data, priority);
	}

	Treap* pop_front() {
		if (left != NULL) {
			left = left->pop_front();
			updateFromChildren();
			return this;
		} else {
			return right;
		}
	}

	Treap* removeLast() {
		if (right != NULL) {
			right = right->removeLast();
			updateFromChildren();
			return this;
		} else {
			return left;
		}
	}

/*	static Treap* remove(Treap* root, int key) {
		if (root == NULL) return NULL;
		if (root->value == key) return merge(root->left, root->right);
		else if (key < root->value) {
			root->left = remove(root->left, key);
			root->updateFromChildren();
			return root;
		} else {
			root->right = remove(root->right, key);
			root->updateFromChildren();
			return root;
		}
	}
*/
	void print(int offset = 0) {
		FOR (i, 0, offset) cout << ' ';

		cout << size << " = ";
		// TODO: print something
		cout << endl;
		if (left != NULL) { cout << "l: "; left->print(offset + 2); }
		if (right != NULL) { cout << "r: "; right->print(offset + 2); }
	}

	TData& front() {
		if (left == NULL) return data;
		return left->front();
	}

	void mark_present(vector<bool> &present) {
		if (data != UNKNOWN) {
			if (present[data]) {
				cout << -1;
				exit(0);
			}
			present[data] = true;
		}
		if (left != NULL) left->mark_present(present);
		if (right != NULL) right->mark_present(present);
	}

	void solve(vector<bool> &present, int &nextCup) {
		if (left != NULL) left->solve(present, nextCup);

		if (data == UNKNOWN) {
			while (present[nextCup]) nextCup++;
			data = nextCup;
			present[nextCup] = true;
		}
		cout << data << ' ';

		if (right != NULL) right->solve(present, nextCup);
	}
};

Treap<int>* root;

class {
	public:

	// vector<pair<int, int>> cups;
	void init(int n) {
		FOR (i, 0, n) {
			// cups.push_back(make_pair(i, UNKNOWN));
			root = Treap<int>::push_back(root, UNKNOWN, rand());
		}
	}

	int get_head() {
		// int c2 = cups.front().second;
		return root->front();
	}

	void set_head(int x) {
		root->front() = x;
		// cups.front().second = x;
	}

	void move_head_to(int pos) {
		int head = root->front();
		root = root->pop_front();
		root = Treap<int>::insertAt(root, pos, head, rand());

		// auto cup = cups.front();
		// cups.front() = cups.back();
		// cups.pop_back();

		// for (auto &x : cups)
			// if (x.first <= pos) x.first--;

		// cup.first = pos;
		// cups.push_back(cup);
		// sort(all(cups));
	}

	void print() {
		// for (auto p : cups) cout << p << "  -  ";
		// cout << endl;
	}

	void solve() {
		vector<bool> present(root->size + 1);

		// for (auto &cup : cups) {
			// if (cup.second != UNKNOWN) {
				// if (present[cup.second]) {
					// cout << -1;
					// exit(0);
				// }
				// present[cup.second] = true;
			// }
		// }

		int nextCup = 1;
		// for (auto &cup : cups) {
			// if (cup.second == UNKNOWN) {
				// while (present[nextCup]) nextCup++;
				// cup.second = nextCup;
				// present[nextCup] = true;
			// }
		// }

		// for (auto &cup : cups) cout << cup.second << ' '; cout << endl;

		present.assign(present.size(), false);
		root->mark_present(present);
		nextCup = 1;
		root->solve(present, nextCup); cout << endl;

	}
} pile;

int main() {
	srand (time(NULL));
    ios_base::sync_with_stdio(false); cin.tie(NULL);

	next(int, n);
	next(int, m);

	pile.init(n);

	auto p = readVector<pair<int, int>>(m);

	FORD (i, m - 1, 0) {
		int pos = p[i].second;
		int mark = p[i].first;

		int head = pile.get_head();
		if (head == UNKNOWN) {
			pile.set_head(mark);
		} else if (head != mark) {
			cout << -1;
			return 0;
		}
		pile.move_head_to(pos - 1);
	}

	pile.solve();
}

#include<iostream>
#include<cstdio>
using namespace std;
struct Splay
{
	Splay *son[2];
	Splay *father;
	int key;
	int size;
	int num;
};
Splay *root;
Splay *nul;
Splay no[1000010];
int pz;
int n, m;
bool mark[1000001];
int ans[1000001];
int z = 1;

Splay* makenode(int p, int q, Splay* f, int r = 1)
{
	Splay *temp;
	temp = &no[++pz];
	temp -> son[0] = temp -> son[1] = nul;
	temp -> father = f;
	temp -> num = p;
	temp -> key = q;
	temp -> size = r;
	return temp;
}

void link(Splay* p, Splay* q, int st)
{
	p -> son[st] = q;
	q -> father = p;
	return ;
}

void rotate(Splay* temp, int flag)
{
	Splay *tf = temp -> father;
	link(tf, temp->son[flag], flag^1);
	if(tf == tf -> father -> son[0])
		link(tf->father, temp, 0);
	else
		link(tf->father, temp, 1);
	link(temp, tf, flag);
	tf -> size = tf -> son[0] -> size + tf -> son[1] -> size + 1;
	temp -> size = temp -> son[0] -> size + temp -> son[1] -> size + 1;
	return ;
}

void splay(Splay* temp, Splay* des)
{
	int x, y;
	while(temp -> father != des)
	{
		if(temp -> father -> son[0] == temp)
			x = 0;
		else
			x = 1;
		if(temp -> father -> father == des)
		{
			rotate(temp, x^1);
			return ;
		}
		if(temp -> father  -> father-> son[0] == temp -> father)
			y = 0;
		else
			y = 1;
		if(x == y)
		{
			rotate(temp->father, y^1);
			rotate(temp, x^1);
		}
		else
		{
			rotate(temp, x^1);
			rotate(temp, y^1);
		}
	}
	return ;
}

Splay* find(int p, Splay* t)
{
	if(p <= t->son[0]->size)
		return find(p, t->son[0]);

	p -= t->son[0] -> size;
	if(p == 1)
		return t;
	p--;
	return find(p, t->son[1]);
}

void solve()
{
	scanf("%d%d", &n, &m);

	Splay *temp, *t1, *t2, *t3;
	temp = root;
	root -> size = n;

	for(int i = n; i >= 1; i--)
		temp = temp -> son[0] = makenode(i, -1, temp, i);
	splay(temp, root);
	int k1, k2;
	for(int i = 1; i <= m; i++)
	{
		scanf("%d%d", &k1, &k2);
		temp = find(k2, root);
		if(mark[k1] && ans[temp -> num] != k1)
		{
			printf("-1\n");
			return ;
		}
		else if(temp -> key == -1)
		{
			temp -> key = k1;
			ans[temp->num] = k1;
			mark[k1] = true;
		}
		else if(temp -> key != k1)
		{
			printf("-1\n");
			return ;
		}
		if(k2 == 1)
			continue;
		t1 = find(k2-1, root);
		splay(t1, root);
		if(k2 == n)
		{
			t2 = find(1, root);
			t1 -> size--;
			t1 -> son[1] = nul;

			splay(t2, root);
			link(t2, temp, 0);
			t2 -> size ++;
			continue;
		}
		t2 = find(k2+1, root);
		splay(t2, t1);

		t3 = find(1, root);
		t1 -> size--;
		t2 -> son[0] = nul;
		t2 -> size--;

		splay(t3, root);
		link(t3, temp, 0);
		t3 -> size ++;
	}
	for(int i = 1; i <= n; i++)
	{
		if(!ans[i])
		{
			while(z <= n && mark[z] == true)
				z++;
			ans[i] = z;
			z++;
		}
		printf("%d ", ans[i]);
	}
	printf("\n");
	return ;
}

int main()
{
	nul = &no[++pz];
	nul -> son[0] = nul -> son[1] = nul;
	nul -> size = 0;
	root = makenode(0, (int)1e9, nul);
	root -> size = 0;
	solve();

	return 0;
}

#include "bits/stdc++.h"
#define MAXN 2000009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int s[MAXN<<2],val[MAXN],ans[MAXN],vis[MAXN];
void upd(int p,int v,int nd,int x,int y){
	if(x==y){
		val[x]=v;
		s[nd]=1-(v==0);
		return;
	}
	int mid=(x+y)>>1;
	if(p<=mid)
		upd(p,v,nd<<1,x,mid);
	else
		upd(p,v,nd<<1|1,mid+1,y);
	s[nd]=s[nd<<1]+s[nd<<1|1];
}
int tap(int p,int nd,int x,int y){
	if(x==y)
		return x;
	int mid=(x+y)>>1;
	if(s[nd<<1]<p)
		return tap(p-s[nd<<1],nd<<1|1,mid+1,y);
	return tap(p,nd<<1,x,mid);
}
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		upd(i+q,i,1,1,n+q);
	int last=q,qq=q;
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		int ind=tap(y,1,1,n+qq);
		int k=val[ind];
		if(!ans[k]){
			if(vis[x]){
				puts("-1");
				return 0;
			}
			ans[k]=x;
		}
		else{
			if(ans[k]!=x){
				puts("-1");
				return 0;
			}
		}
		vis[x]=1;
		upd(ind,0,1,1,n+qq);
		upd(last,k,1,1,n+qq);last--;
	}
	int p=1;
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			while(p<=n and ans[p])
				p++;
			ans[p]=i;p++;
		}
	for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	puts("");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int N = 2e6 + 5;

int n, m, bit[N], id, task[N], used[N], realpos[N];
vector<int> tmp;
void update(int pos, int val) {
    while(pos < N) {
        bit[pos] += val;
        pos += pos & (-pos);
    }
}

int findpos(int x) {
    int sum = 0, pos = 0;
    for(int i = 21; i >= 0; i--) {
        if(pos + (1 << i) < N && sum + bit[pos + (1 << i)] < x) {
            sum += bit[pos + (1 << i)];
            pos += (1 << i);
        }
    }
    return pos + 1;
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= 2e6 + 1; i++)
        task[i] = -1;
    for(int i = 1e6 + 1; i <= 2e6 + 1; i++)
        update(i, 1);
    id = 1e6;
    int sum = 0;
    while(m--) {
        int x, y;
        scanf("%d%d", &x, &y);
        sum++;
        int pos = findpos(y);
        if(task[pos] == x) {
            task[pos] = 0;
            update(pos, -1);
            update(id, 1);
            task[id] = x;
            id--;
        }
        else if(task[pos] == -1 && used[x] == 0) {
            realpos[pos] = x;
            used[x] = 1;
            task[pos] = 0;
            update(pos, -1);
            update(id, 1);
            task[id] = x;
            id--;
        }
        else {
            printf("-1\n");
            exit(0);
        }
    }
    for(int i = n; i >= 1; i--) {
        if(!used[i])
            tmp.pb(i);
    }
    for(int i = 1e6 + 1; i <= 1e6 + 1 + n; i++) {
        if(realpos[i])
            printf("%d ", realpos[i]);
        else {
            if(tmp.size()) {
                printf("%d ", tmp[tmp.size() - 1]);
                tmp.pop_back();
            }
        }
    }
}

#include <cstdio>
#include <ext/pb_ds/assoc_container.hpp>
#define rep(i,s,e) for (int i=(s);i<=(e);++i)
using namespace __gnu_pbds;

const int N=1<<20;
int n, m, lo, mid, p[N], R[N];
tree<int,int,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> t;

int main() {
	scanf("%d%d",&n,&m);
	lo = mid = m + 99;
	rep(i,mid+1,mid+n) t.insert(std::make_pair(i,1));
	rep(i,1,m) {
		int x, y; scanf("%d%d",&x,&y);
		if (!p[x]) {
			p[x] = t.find_by_order(y-1)->first;
			if (p[x] <= mid) { puts("-1"); return 0; }
			R[p[x] - mid] = x;
		}
		if (p[x] != t.find_by_order(y-1)->first) { puts("-1"); return 0; }
		t.erase(p[x]);
		t.insert(std::make_pair(p[x]=lo--,1));
	}
	int r = 1;
	rep(i,1,n) if (!p[i]) {
		while (R[r]) ++r;
		R[r] = i;
	}
	rep(i,1,n) printf("%d ",R[i]);
	puts("");
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
using namespace std;
static const int INF =500000000;
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

struct segtree{
	int val[8000005];
	int n;
	void init(int n_,int m){//n_=n+m
		n=1;
		while(n<n_) n<<=1;
		REP(i,n*2) val[i]=0;
		REPN(i,n_,m) val[i+n-1]=1;

		for(int i=n-2;i>=0;--i) val[i]=val[i*2+1]+val[i*2+2];
	}
	void set(int k,int a){
		k+=n-1;
		val[k]=a;
		while(k>0){
			k=(k-1)/2;
			val[k]=val[k*2+1]+val[k*2+2];
		}
	}
	int query(int i,int l,int r,int k){
		if(val[i]<k) return INF;
		if(r-l==1) return l;

		int md=(l+r)>>1;
		int L=query(i*2+1,l,md,k);
		if(L==INF) return query(i*2+2,md,r,k-val[i*2+1]);
		else return L;
	}
};
segtree seg;

int n,m;
pi event[1000005];

int ar[2000005];//[position],position

int res[1000005];//[pos],mark

int used[1000005];//[mark]
int main(){
	cin>>n>>m;
	REP(i,m){
		scanf("%d%d",&event[i].fr,&event[i].sc);
		--event[i].fr;--event[i].sc;
	}
	memset(res,-1,sizeof(res));
	memset(ar,-1,sizeof(ar));
	REP(i,n) ar[i+m]=i;
	seg.init(n+m,m);

	REP(i,m){
		int x=event[i].fr,y=event[i].sc;

		int pos=seg.query(0,0,seg.n,y+1);
		int init_pos=ar[pos];
		if(res[init_pos]!=-1 && res[init_pos]!=x){
			puts("-1");
			return 0;
		}
		if(res[init_pos]==-1 && used[x]){
			puts("-1");
			return 0;
		}

		used[x]=1;
		res[init_pos]=x;

		ar[pos]=INF;
		seg.set(pos,0);
		seg.set(m-i-1,1);
		ar[m-i-1]=init_pos;
	}

	int j=0;
	REP(i,n)  if(res[i]==-1){
		while(used[j]) ++j;
		res[i]=j;
		++j;
	}

	REP(i,n) printf("%d%c",res[i]+1,i==n-1?'\n':' ');

	return 0;
}

/*
I lost my mind
I lost myself
I kept on falling
Straight down to hell

Stood at the crossroads
I needed a sign
To find my way
Out of the night

As the light seemed to be too far away
The answer to every prayer
Looked into my eyes and took my hand

(It took)
Two hearts but only one wish
Two hearts, together we're strong
(It took)
Two hearts but only one wish
Two hearts, together we're strong

The wheels of life
Spinning around
I kept on'falling
No feet on the ground

Reached out for something
But I forgot to give
It took an angel to show me how to live

As the light seemed to be too far away
The answer to every prayer
Looked into my eyes and took my hand

(It took)
Two hearts but only one wish
Two hearts, together we're strong
(It took)
Two hearts but only one wish
Two hearts, together we're strong
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long n,m;
long subsize[10000000],ar[10000000];
long x,y,tp,er;
vector<long> ans;
long anss[3000000];
long q;
set<long> f;
set<long>::iterator it;
long usd[2000000];

void build (long v,long tl,long tr)
{
 if (tl==tr){if (tl>1000000&&tl<=1000000+n)subsize[v]=1;return ;}
 long tm=tl+tr;
 tm/=2;
 build(v*2,tl,tm);
 build(v*2+1,tm+1,tr);
 subsize[v]=subsize[v*2]+subsize[v*2+1];
}

long solve(long v,long tl,long tr,long need)
{
 if (tl==tr)
 {return tl;}
 long tm=tl+tr;
 tm/=2;
 if (subsize[v*2]>=need){return solve(v*2,tl,tm,need);}
 need-=subsize[v*2];
 return solve(v*2+1,tm+1,tr,need);
}

void update(long v,long tl,long tr,long ps,long val)
{
 if (tl==tr){ar[tl]=val;if (val==0)subsize[v]=0;else subsize[v]=1;return;}
 long tm=tl+tr;
 tm/=2;
 if (ps<=tm){update(v*2,tl,tm,ps,val);}
 else update(v*2+1,tm+1,tr,ps,val);
 subsize[v]=subsize[v*2]+subsize[v*2+1];
}

int main(){
//freopen("partition.in","r",stdin);
//freopen("partition.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
//cin.tie(0);

cin>>n>>m;
build(1,1,2000000);

for (int i=1;i<=m;i++)
{
 cin>>x>>y;
 tp=solve(1,1,2000000,y);
 //cout<<tp<<" "<<ar[tp]<<endl;
 if (ar[tp]!=0&&ar[tp]!=x){er=1;}
 anss[tp]=x;
 update(1,1,2000000,tp,0);
 update(1,1,2000000,1000001-i,x);
}

for (int i=1;i<=n;i++)
f.insert(i);

for (int i=1000001;i<=1000000+n;i++)
{
 if (anss[i]==0)continue;
 if (usd[anss[i]])er=1;
 usd[anss[i]]=1;
 f.erase(anss[i]);
}

for (int i=1;i<=n;i++)
{
 if (anss[i+1000000]==0){it=f.begin();q=(*it);f.erase(it);ans.push_back(q);}
 else
 {
  ans.push_back(anss[i+1000000]);
 }
}
if (er)cout<<-1<<endl;else
{
for (int i=0;i<ans.size();i++)
{if (i)cout<<" ";cout<<ans[i];}
cout<<endl;
}
cin.get();cin.get();
return 0;}

//Author: net12k44
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <algorithm>

using namespace std;

#define For(i,a,b)  for(i=(a);i<=(b);++i)
#define Ford(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,n)    for(i=0  ;i <(n);++i)
#define Repd(i,n)   for(i=(n-1);i>=0;--i)
#define FOR(i,a,b)  for(i=(a);i!=(b);i++)

#define pp  pair<int,int>
template<class T> void minimize( T &i , const T &j ) { if ( i > j ) i = j; }
template<class T> void maximize( T &i , const T &j ) { if ( i < j ) i = j; }

int NUM, AM;
#define SIZE (1 << 16)
char BUFFER[SIZE+1], *pNum = BUFFER;
#define GET(NUM)\
{\
      if (!*pNum)\
      {\
            if (feof(stdin) ) memset(BUFFER,0,sizeof BUFFER);\
            else fread(BUFFER, 1, SIZE, stdin); pNum = BUFFER;\
      } NUM = *pNum++;\
}
#define IsNum(c) ( ('0' <= (c)) && ((c) <= '9' ) )
#define nextInt(i){\
      do  GET(NUM) while(!IsNum(NUM) && NUM!='-' );\
      if (NUM == '-') {AM=1; GET(NUM);} else AM=0;\
      i = NUM-'0'; GET(NUM);\
      while( IsNum(NUM) ) { i = i * 10 + (NUM-'0'); GET(NUM); }\
      if (AM) i = -i;\
}
#define thapphan(i) {\
	int K = 1; GET(NUM);\
	while ( IsNum(NUM) ) { K*=10; i = i * 10 + (NUM-'0'); GET(NUM); }\
	i =i / K;\
}
#define nextDouble(i){\
      do  GET(NUM) while(!IsNum(NUM) && NUM!='-' && NUM!='.' );\
      if (NUM == '-') {AM=1; GET(NUM);} else AM=0; i = 0;\
      if (NUM != '.') while( IsNum(NUM) ) { i = i * 10 + (NUM-'0'); GET(NUM); }\
	  if (NUM == '.') thapphan(i);\
      if (AM) i = -i;\
}

int MAIN();

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("file.inp","r",stdin);
//		freopen("file.out","w",stdout);

		#ifdef TEST_JUDGE
			freopen("file.out","w",stdout);
		#endif
	#endif

	MAIN();

	#ifndef ONLINE_JUDGE
			fprintf(stderr,"\n");
            fprintf(stderr,"%.2lf\n", (double) clock() / CLOCKS_PER_SEC);
    #endif
	return 0;
}

//Treap data structure
//Base on e-maxx.ru
struct Treap{
	struct Node{
		int value, priority, size;
		Node *Left, *Right;
		Node(){}
		Node(int value){
			this->value = value;
			priority = rand()%RAND_MAX;
			size = 1;
			this->Left = this->Right = NULL;
		}
		~Node() {delete Left; delete Right;}

	};
	typedef Node* node;

	node root;
	Treap(): root(NULL) {}
	~Treap() {delete root;}

	//size of subtree node r
	//default to the size of this Treap
	int size(node r){
		if (r == NULL) return 0;
		return r->size;
	}
	int size() {return size(root);}

	//update the size of node
	//Can extend to update other thing.
	void update(node r){
		if (r) r->size = size(r->Left) + size(r->Right) + 1;
		//else r->size = 0;
	}

	//merge subtree Left and subtree Right to subtree r;
	void merge(node &r, node Left, node Right){
		if (!Left || !Right) r = Left ? Left:Right;
		else if ( Left->priority > Right->priority )
			merge( Left->Right, Left->Right,Right ), r = Left;
		else
			merge( Right->Left, Left, Right->Left ), r = Right;
		update(r);
	}

	//split subtree root r to subtree Left and subtree Right
	//which subtree Left have [0..position-1]
	void split(node r, node &Left, node &Right, int pos, int add = 0){
		if (!r) return void (Left = Right = NULL);
		int cur_pos = add + size(r->Left); //Calculate current position
		if (pos <= cur_pos)
			split(r->Left, Left, r->Left, pos, add), Right = r;
		else
			split(r->Right, r->Right, Right, pos, add + 1 + size(r->Left)), Left = r;
		update(r);
	}

	//insert new value to position
	void insert(int value, int position){
		node p = new Node(value);

		node Right;
		split(root, root, Right, position);
		merge(root, root, p);
		merge(root, root, Right);
	}

	node find(int position){
		node p = root;
		int cur_pos = 0;
		while (true){
			if (cur_pos + size(p->Left) > position) p = p->Left;
			else {
				cur_pos += size(p->Left);
				if (cur_pos == position) return p;
				else cur_pos++, p = p->Right;
			}
		}
	}

	int& operator[] (int position){
		return find(position)->value;
	}

	void erase(node &r, int position, int add = 0){
		int cur_pos = add + size(r->Left);
		if (cur_pos == position) merge(r, r->Left, r->Right);
		else if (cur_pos > position) erase(r->Left,position,add);
		else erase(r->Right,position,add + size(r->Left) + 1);
		update(r);
	}

	void erase(int position){
		erase(root, position);
	}

}a;

const int limit = 1000000 + 5;
int x[limit], y[limit];
bool b[limit];

int MAIN(void)
{
	int n,m;
	nextInt(n); nextInt(m);
	for(int i = 0; i < n; ++i) a.insert(-1, a.size());
	for(int i = 0; i < m; ++i){
		nextInt(x[i]); nextInt(y[i]);
	}

	b[0] = true;
	for(int i = m-1; i >= 0; --i){
		int cur = a[0];
		if ( (cur == -1 && b[ x[i] ]) || (cur != -1 && cur != x[i]) )
			return printf("-1"), 0;

		if (cur == -1) cur = x[i]; b[cur] = true;
		a.erase(0);
		a.insert(cur, y[i] - 1);
	}

	int k = 0;
	for(int j = 0; j < n; ++j){
		int i = a[j];
		if (i == -1) while (b[k]) i = ++k;
		b[i] = true; printf("%d ",i);
	}
	return 0;
}

//+-------------------------------------+
//|     By   qwer_zcc                   |
//|     Date 13/04/2014                 |
//+-------------------------------------+
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#define INF 1000000000
#define LL long long
#define uLL unsigned long long
#define uint unsigned int
#define D double
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define dep(i,a,b) for (int i=a;i>=b;i--)
#define M(a) memset(a,0,sizeof(a));
#define pb push_back
#define mp make_pair
#define ins insert
#define ps push
#define Pi M_PI
using namespace std;
template<class T> inline T abs(T &a) {return a>0?a:-a;}
template<class T> inline T min(T &a,T &b) {return a<b?a:b;}
template<class T> inline T max(T &a,T &b) {return a>b?a:b;}
inline void read(int &x)
{
	char ch;
	while ((ch=getchar()) && !(ch>='0' && ch<='9'));x=ch-'0';
	while ((ch=getchar()) && (ch>='0' && ch<='9')) x=x*10+ch-'0';
}
const int N=2000002;
int n,m,w[N],ans[N],dy[N],T=1,t[N<<2];
void add(int x,int c)
{
	for (t[x+=T]+=c,x>>=1;x;x>>=1) t[x]=t[x<<1]+t[(x<<1)+1];
}
int find(int k,int l,int r)
{
	int x=1;
	while (l<r)
	{
		int mid=l+r>>1;
		if (t[x<<1]>=k) x=x<<1,r=mid;
		else k-=t[x<<1],x=x<<1|1,l=mid+1;
	}
	return l;
}

int main()
{
	read(n);read(m);
	int Len=n+m,gs=0;
	while (T<Len) T<<=1,gs++;T--;
	rep(i,m+1,n+m) w[i]=i-m,add(i,1);
	int x,y;
	dep(i,m,1)
	{
		read(x);read(y);
		int p=find(y,1,T+1);
		w[i]=w[p];
		add(i,1);add(p,-1);
		if (ans[w[i]] && ans[w[i]]!=x) {puts("-1");return 0;}
		ans[w[i]]=x;
		if (dy[x] && dy[x]!=w[i]) {puts("-1");return 0;}
		dy[x]=w[i];
	}
	int j=1;
	rep(i,1,n)
	{
		if (ans[i]) printf("%d ",ans[i]);
		else {for(;dy[j];j++);printf("%d ",j++);}
	}
}

#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int x[1000010], y[1000010];
bool used[1000010];

struct fhq_Treap{
    struct T{
        int lc;
        int rc;
        int v;
        int w;
        int size;
    }t[2000010];
    int root = 0;
    int cnt = 0;
    int cc = 0;

    void push_up(int cur){
        t[cur].size = t[t[cur].lc].size + t[t[cur].rc].size + 1;
    }

    void split(int cur, int &a, int &b, int k){
        if(!cur){
            a = b = 0;
            return ;
        }
        if(t[t[cur].lc].size >= k){
            b = cur;
            split(t[cur].lc, a, t[b].lc, k);
            push_up(b);
        } else {
            a = cur;
            split(t[cur].rc, t[a].rc, b, k - t[t[cur].lc].size - 1);
            push_up(a);
        }
    }

    int merge(int a, int b){
        if(!a || !b)
            return a + b;
        if(t[a].w < t[b].w){
            t[a].rc = merge(t[a].rc, b);
            push_up(a);
            return a;
        } else {
            t[b].lc = merge(a, t[b].lc);
            push_up(b);
            return b;
        }
    }

    int begin(){
        int cur = root;
        while(t[cur].lc)
            cur = t[cur].lc;
        return t[cur].v;
    }

    void erase(){
        int x;
        split(root, x, root, 1);
    }

    void insert(int x, int pos){
        int l, r;
        split(root, l, r, pos - 1);
        t[++cnt] = (T){0, 0, x, rand(), 1};
        root = merge(merge(l, cnt), r);
    }

    void print(int cur){
        if(cur == 0)
            return ;
        print(t[cur].lc);
        if(!t[cur].v){
            cc++;
            while(used[cc])
                cc++;
        }
        printf("%d ", t[cur].v ? t[cur].v : cc);
        print(t[cur].rc);
    }
}t;

int main(){
    int n = inp();
    int m = inp();
    for(int i = 1; i <= n; i++)
        t.insert(0, i);
    for(int i = 1; i <= m; i++){
        x[i] = inp();
        y[i] = inp();
    }
    for(int i = m; i >= 1; i--){
        int st = t.begin();
        if((used[x[i]] && st != x[i]) || (st != x[i] && st != 0)){
            printf("-1\n");
            return 0;
        }
        t.erase();
        t.insert(x[i], y[i]);
        used[x[i]] = true;
    }
    t.print(t.root);
    putchar('\n');
}
// ...

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(x) (int)x.size()
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N=1000007, S=N-4;

int n,m;
int cnt[N<<1], ans[N], pre[N<<1];
bool vis[N];

void upd(int p,int c) {
	for(int i=p;i<=S+S;i+=(i&-i)) cnt[i]+=c;
}
int qry(int p) {
	int res=0;
	for(int i=p;i;i-=(i&-i)) res+=cnt[i];
	return res;
}

int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,S+1) upd(i+S, 1);
	int p=S;
	rep(i,1,m+1) {
		int v, x;scanf("%d%d",&v,&x);
		int l=1, r=S+S, res=-1;
		while(l<=r) {
			int mid=l+r>>1;
			if(qry(mid)<x) {
				res=mid+1;
				l=mid+1;
			} else {
				r=mid-1;
			}
		}
		if(res>S) {
			if(vis[v]) {
				puts("-1");
				return 0;
			}
			vis[v]=1;
			ans[res-S]=v;
		} else {
			if(pre[res]!=v) {
				puts("-1");
				return 0;
			}
		}
		upd(res, -1);
		upd(p, 1);
		pre[p]=v;
		--p;
	}
	for(int i=1,j=1;i<=n;++i) if(!ans[i]) {
		while(vis[j]) ++j;
		ans[i]=j;
		vis[j]=1;
	}
	rep(i,1,n+1) printf("%d%c",ans[i]," \n"[i==n]);
	return 0;
}

/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <list>
#include <iomanip>
#include <math.h>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <tr1/unordered_set>
#include <tr1/unordered_map>

using namespace std;
using namespace tr1;

#define mpr make_pair
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <double, double> pdd;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <double> vd;
typedef vector <string> vs;
typedef map <string, int> mpsi;
typedef map <double, int> mpdi;
typedef map <int, int> mpii;

const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;
const int step[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}

template <class T> inline T max1(T a, T b) { return a > b ? a : b; }
template <class T> inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }
template <class T> inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }
template <class T> inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }
template <class T> inline T min1(T a, T b) { return a < b ? a : b; }
template <class T> inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }
template <class T> inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }
template <class T> inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }

inline int jud(double a, double b){
	if(abs(a) < eps && abs(b) < eps) return 0;
	else if(abs1(a - b) / abs1(a) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
template <typename t> inline int jud(t a, t b){
	if(a < b) return -1;
	if(a == b) return 0;
	return 1;
}

// f_lb == 1代表返回相同的一串的左边界，f_small == 1代表返回如果没有寻找的值返回小的数
template <typename it, typename t1>
inline int find(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1){
	int be = 0, en = na - 1;
	if(*a <= *(a + na - 1)){
		if(f_lb == 0) while(be < en){
			int mid = (be + en + 1) / 2;
			if(jud(*(a + mid), val) != 1) be = mid;
			else en = mid - 1;
		}else while(be < en){
			int mid = (be + en) / 2;
			if(jud(*(a + mid), val) != -1) en = mid;
			else be = mid + 1;
		}
		if(f_small && jud(*(a + be), val) == 1) be--;
		if(!f_small && jud(*(a + be), val) == -1) be++;
	} else {
		if(f_lb) while(be < en){
			int mid = (be + en + 1) / 2;
			if(jud(*(a + mid), val) != -1) be = mid;
			else en = mid - 1;
		}else while(be < en){
			int mid = (be + en) / 2;
			if(jud(*(a + mid), val) != 1) en = mid;
			else be = mid + 1;
		}
		if(!f_small && jud(*(a + be), val) == -1) be--;
		if(f_small && jud(*(a + be), val) == 1) be++;
	}
	return be;
}

template <class T> inline T lowb(T num) {return num & (-num); }
inline int bitnum(ui nValue) { return __builtin_popcount(nValue); }
inline int bitnum(int nValue) { return __builtin_popcount(nValue); }
inline int bitnum(ull nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }
inline int bitnum(ll nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }
inline int bitmaxl(ui a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }
inline int bitmaxl(int a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }
inline int bitmaxl(ull a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }
inline int bitmaxl(ll a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }

long long pow(long long n, long long m, long long mod = 0){
	if(m < 0) return 0;
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

#define  MOD 1000000007
template <class t1, class t2>
inline void add(t1 &a, t2 b) {
	a += b;
	while(a >= MOD) a -= MOD;
	while(a < 0) a += MOD;
}

//#define debug
//.........................mi.......feng......xian.......xia.......jin.......zhi.......hack...............................................

#ifndef N
#define N 1 << 21
#endif
template <class t> struct tree_array{
	t num[N], n, bigwei;
	void init(int nn = N){
		n = nn;
		while(lowb(nn) != nn) nn -= lowb(nn);
		bigwei = nn;
		n = bigwei * 2;
	}
	void upd(int no, t add){
		while(no <= n){
			num[no] += add;
			no += lowb(no);
		}
	}
	t que(int no){
		t ans = 0;
		while(no){
			ans += num[no];
			no -= lowb(no);
		}
		return ans;
	}
	 int getrank(t x){
		 int ans = 0, ranwei = bigwei; t rank = 0;
		 while(ranwei){
			 if(rank + num[ranwei + ans] < x){
				 ans += ranwei;
				 rank += num[ans];
			 }
			 ranwei >>= 1;
		 }
		 return ans + 1;
	 }
};
tree_array <int> ta;
const int maxn = N;
pii arr[maxn];
int ans[maxn], have[maxn];
int n, m;

int main(){
    ios_base::sync_with_stdio(0);
	#ifdef debug //......................................................................................................
	freopen("input.txt", "r", stdin);
	#endif //...........................................................................................................
	scanf("%d%d", &n, &m);
	memset(arr, -1, sizeof(arr));
	ta.init(n + m + 10);
	for(int i = 1; i <= n; i++) ta.upd(i + m, 1);
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		int no = ta.getrank(b);
		if(arr[no].first == -1) {
			if(have[a]) {
				cout << -1 << endl;
				return 0;
			}
			arr[no].first = a;
			arr[no].second = no;
		} else if(arr[no].first != a){
			cout << -1 << endl;
			exit(0);
		}
		have[a] = 1;
		swap(arr[no], arr[m - i]);
		ta.upd(no, -1);
		ta.upd(m - i, 1);
	}
	for(int i = 0; i < n + m + 10; i++) if(arr[i].first != -1) {
		ans[arr[i].second - 1 - m] = arr[i].first;
		have[arr[i].first] = 1;
	}
	int link = 1;
	for(int i = 0; i < n; i++) {
		if(ans[i] == 0) {
			while(have[link]) link++;
			ans[i] = link;
			have[link] = 1;
		}
	}
	for(int i = 0; i < n; i++) printf("%d ", ans[i]);
	printf("\n");

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
#define lch x<<1
#define rch x<<1|1

int n, m, a[1100000], b[1100000], c[2100000];

struct node{
	int l, r, s;
}T[8000000];
void Build(int L, int R, int x){
	T[x].l = L, T[x].r = R;
	if (L == R) T[x].s = L > m;
	else{
		Build(L, L+R>>1, lch);
		Build((L+R>>1)+1, R, rch);
		T[x].s = T[lch].s+T[rch].s;
	}
}
int find(int y){
	int x(1);
	while (T[x].l < T[x].r){
		if (T[lch].s >= y) x = lch;
		else{ y -= T[lch].s; x = rch; }
	}
	return T[x].l;
}
void Modify(int y, int d){
	int x(1);
	while (T[x].l < T[x].r){
		T[x].s += d;
		x = y <= T[lch].r ? lch : rch;
	}
	T[x].s += d;
}

int main(){
	scanf("%d%d", &n, &m);
	REP(i,n) c[m+i] = i;
	Build(1, n+m, 1);
	int x, y, t;
	ROF(i,m,1){
		scanf("%d%d", &x, &y);
		t = find(y);
		c[i] = c[t];
		Modify(t, -1); Modify(i, 1);
		if (a[c[i]] && a[c[i]] != x){ printf("-1\n"); return 0; }
		a[c[i]] = x;
		if (b[x] && b[x] != c[i]){ printf("-1\n"); return 0; }
		b[x] = c[i];
	}

	t = 1;
	REP(i,n) if (!a[i]){
		while (b[t]) ++t;
		a[i] = t;
		++t;
	}
	REP(i,n-1) printf("%d ", a[i]); printf("%d\n", a[n]);
	return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define N 1000010
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)>(y)?(x):(y))
#define LL __int64
using namespace std;
struct info
{
	int x,y;
}a[1010000];
struct node
{
	int id;
}q[3010000];
struct nd
{
	int l,r,x;
}tree[8010000];
int n,m,ans[3010000],num[1010000];
bool bo[1010000];
void change(int x,int y,int p)
{
	tree[p].x+=y;
	if(tree[p].l==tree[p].r) return;
	int lef=p<<1,rig=p<<1|1;
	if(tree[lef].r>=x) change(x,y,lef);
	else change(x,y,rig);
}
int search(int y,int p)
{
	if(tree[p].l==tree[p].r) return tree[p].l;
	int lef=p<<1,rig=p<<1|1;
	if(tree[lef].x>=y) return search(y,lef);
	else return search(y-tree[lef].x,rig);
}
void mtree(int l,int r,int p)
{
	tree[p].l=l; tree[p].r=r;
	if(l==r)
	{
		if(l>m&&l<=m+n) tree[p].x=1;
		return;
	}
	int lef=p<<1,rig=p<<1|1,mid=(l+r)>>1;
	mtree(l,mid,lef);
	mtree(mid+1,r,rig);
	tree[p].x=tree[lef].x+tree[rig].x;
}
int main()
{
	int i,j,k,t,T,x,y,xx,yy,p,z,id,now;
	int tail;
	scanf("%d%d",&n,&m);
	mtree(1,m+n,1);
	for(i=m+1;i<=m+n;i++)
	{
		q[i].id=i-m;
	}
	tail=m+1;
	bool flag=true;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i].x,&a[i].y);
		x=search(a[i].y,1);
		change(x,-1,1);
		if(ans[q[x].id]!=0&&ans[q[x].id]!=a[i].x) flag=false;
		if(ans[q[x].id]==0)
		{
			ans[q[x].id]=a[i].x;
			num[a[i].x]++;
			if(num[a[i].x]>1) flag=false;
		}
		tail--;
		q[tail].id=q[x].id;
		bo[a[i].x]=true;
		change(tail,1,1);
	}
	if(!flag)
	{
		puts("-1");
		return 0;
	}
	for(i=j=1;i<n;i++)
		if(ans[i])
			printf("%d ",ans[i]);
		else
		{
			while(bo[j]) j++;
			printf("%d ",j++);
		}
	if(ans[n])
		printf("%d\n",ans[n]);
	else
	{
		while(bo[j]) j++;
		printf("%d\n",j++);
	}
}

#include <bits/stdc++.h>
#define maxn 1000005
using namespace std;
struct Node {
    Node *l, *r;
    int id, val, pri, sz, tag;
    Node(int _id, int _val) : l(nullptr), r(nullptr),
        id(_id), val(_val), pri(rand()), sz(1), tag(0) {}
};

int size(Node *x) {
    return x ? x -> sz : 0;
}

void pull(Node *x) {
    if(!x) return;
    x -> sz = size(x -> l) + size(x -> r) + 1;
}

void push(Node *x) {
    if(!x) return;
    if(x -> tag) {
        x -> val += x -> tag;
        if(x -> l) x -> l -> tag += x -> tag;
        if(x -> r) x -> r -> tag += x -> tag;
        x -> tag = 0;
    }
}

Node *merge(Node *a, Node *b) {
    if(!a) return b;
    if(!b) return a;
    if(a -> pri > b -> pri) {
        push(a);
        a -> r = merge(a -> r, b);
        pull(a); return a;
    }
    else {
        push(b);
        b -> l = merge(a, b -> l);
        pull(b); return b;
    }
}

void split(Node *s, Node *&a, Node *&b, int k) {
    if(!s) {
        a = b = nullptr;
        return;
    }
    push(s);
    if(s -> val > k) {
        split(s -> l, a, b, k);
        s -> l = b; pull(s);
        b = s;
    }
    else {
        split(s -> r, a, b, k);
        s -> r = a; pull(s);
        a = s;
    }
}

void insert(Node *&T, int id, int val) {
    Node *a, *b, *c;
    split(T, a, c, val);
    b = new Node(id, val);
    T = merge(a, b);
    T = merge(T, c);
}

Node *find(Node *s, int k) {
    if(!s) return nullptr;
    push(s);
    if(s -> val == k)
        return s;
    else if(s -> val > k)
        return find(s -> l, k);
    else
        return find(s -> r, k);
}

int x[maxn], y[maxn], ans[maxn] = {};
int n, m;

void solve(Node *x) {
    if(!x) return;
    push(x);
    ans[x -> val] = x -> id;
    solve(x -> l);
    solve(x -> r);
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++) {
        scanf("%d%d", x + i, y + i);
    }
    Node *rt = nullptr;
    Node *a, *b, *c, *tmp;
    for(int i = m; i > 0; i--) {
        split(rt, b, c, y[i]);
        tmp = find(b, 1);
        if(tmp) {
            if(tmp -> id != x[i]) {
                puts("-1");
                return 0;
            }
            else {
                split(b, a, b, 1);
                if(b) b -> tag--;
                insert(b, x[i], y[i]);
                if(a) delete a;
                rt = merge(b, c);
            }
        }
        else {
            if(b) b -> tag--;
            insert(b, x[i], y[i]);
            rt = merge(b, c);
        }
    }
    solve(rt);
    set<int> st;
    for(int i = 1; i <= n; i++) st.insert(i);
    for(int i = 1; i <= n; i++) {
        if(ans[i]) {
            st.erase(ans[i]);
        }
    }
    for(int i = 1; i <= n; i++) {
        if(!ans[i]) {
            ans[i] = *st.begin();
            st.erase(ans[i]);
        }
    }
    st.clear();
    for(int i = 1; i <= n; i++) {
        if(st.count(ans[i])) {
            puts("-1");
            return 0;
        }
        st.insert(ans[i]);
    }
    for(int i = 1; i <= n; i++) {
        printf("%d%c", ans[i], " \n"[i == n]);
    }
    return 0;
}

#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

const int N = 1e6+5;

int vals[N], found[N];

struct node {
    node *left, *right; int val, size, priority;
    node(int v)  {
        val = v, size = 1, priority=rand(), left=NULL, right=NULL;
    }
};

int sz(node* t) {
    return (t)?t->size:0;
}

void upd_sz(node* &t)   {
    if(t) t->size = sz(t->left)+1+sz(t->right);
}

void split(node* t, node* &l, node* &r, int k)  {
    if(!t) l=r=NULL;
    else if(sz(t->left)+1<=k) split(t->right, t->right, r, k-sz(t->left)-1), l=t;
    else split(t->left, l, t->left,k), r=t;
    upd_sz(t);
}

void merge(node* &t, node* l, node* r)  {
    if(!l || !r) t=l?l:r;
    else if(l->priority>=r->priority) merge(l->right,l->right,r), t=l;
    else merge(r->left, l,r->left), t=r;
    upd_sz(t);
}

int main() {
    srand(time(NULL));
    int n,m,x,y;
    scanf("%d %d",&n,&m);

    node* t=NULL;
    for (int i=1; i<=n; i++) {
        merge(t, t, new node(i));
    }
    node* a; node* b;

    while (m--) {
        scanf("%d %d",&x,&y);
        split(t, a, t, y);
        split(a, a, b, y-1);

        if(vals[b->val]==x) {

        }
        else if(vals[b->val]==0 && found[x]==0)
            vals[b->val]=x;
        else {
            printf("-1\n"); return 0;
        }
        found[x]=1;
        merge(a, b, a);
        merge(t, a, t);

    }
    int f=1;
    for (int i=1; i<=n; i++) {
        if(vals[i]==0)  {
            while (found[f]!=0) {
                f++;
            }
            vals[i]=f++;
        }
    }
    for (int i=1; i<=n; i++) {
        printf("%d ",vals[i]);
    }
    printf("\n");
    return 0;
}

#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#define N 1000010
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
struct ww {
	int a,l,ll,key,sum;
} a[N];
int i,j,k,n,m,root;
int id[N],x[N],y[N];
inline void fail() {
	printf("-1\n");
	exit(0);
}
inline void update(int x) {
	int y=a[x].l,z=a[x].ll;
	a[x].sum=a[y].sum+a[z].sum+1;
}
inline void right(int x) {
	int y=a[x].a,z=a[y].a;
	if (a[z].l==y) a[z].l=x; else a[z].ll=x;
	a[x].a=z,a[y].a=x; a[y].l=a[x].ll;
	a[x].ll=a[a[y].l].a=y; update(y);
}
inline void left(int x) {
	int y=a[x].a,z=a[y].a;
	if (a[z].l==y) a[z].l=x; else a[z].ll=x;
	a[x].a=z,a[y].a=x; a[y].ll=a[x].l;
	a[x].l=a[a[y].ll].a=y; update(y);
}
inline void splay(int x) {
	int y,z;
	for (;a[x].a;) {
		y=a[x].a,z=a[y].a;
		if (z) if (a[z].l==y)
			if (a[y].l==x) right(y),right(x); else left(x),right(x);
			else if (a[y].l==x) right(x),left(x); else left(y),left(x);
			else if (a[y].l==x) right(x); else left(x);
	}
	update(x); root=x;
}
inline int find(int t,int x) {
	for (;t;) {
		if (a[a[t].l].sum+1==x) return t;
		if (a[a[t].l].sum<x) x-=a[a[t].l].sum+1,t=a[t].ll;
		else t=a[t].l;
	}
	return 0;
}
inline void work(int x,int y) {
	if (!id[x]) {
		int A=find(root,1);
		if (a[A].key) fail();
		splay(A);
		id[x]=A;
		a[A].key=x;
	}
	int A=id[x];
	splay(A);
	if (a[A].l) fail();
	if (y==1) return;
	int B=a[A].ll;
	a[B].a=0;
	root=B;
	int C=find(B,y-1);
	splay(C);
	int D=a[C].ll;
	a[A].a=C;
	a[D].a=A;
	a[C].ll=A;
	a[A].ll=D;
	update(A);
	update(C);
}
void dfs(int x) {
	if (!x) return;
	dfs(a[x].l);
	if (a[x].key) printf("%d ",a[x].key);
	else {
		for (i++;i<=n&&id[i];i++);
		printf("%d ",i);
	}
	dfs(a[x].ll);
}
int main() {
	//freopen("420d.in","r",stdin);
	scanf("%d%d",&n,&m);
	For(i,1,m) scanf("%d%d",&x[i],&y[i]);
	for (i=n;i>1;i--) a[i].a=i-1,a[i-1].ll=i,update(i);
	root=1; update(1);
	for (i=m;i;i--) work(x[i],y[i]);
	i=0;
	dfs(root);
	printf("\n");
	//for(;;);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N = 2000000 + 10;
int sum[N<<2];
void update(int k,int l,int r,int x,int v){
    if(l==r){
        sum[k] += v;
        return;
    }
    int mid = (l + r) >> 1;
    if(x<=mid) update(k<<1,l,mid,x,v);
    else update(k<<1|1,mid+1,r,x,v);
    sum[k] = sum[k<<1] + sum[k<<1|1];
}
int query(int k,int l,int r,int v){
    if(l==r) return l;
    int mid = (l + r) >> 1;
    if(v<=sum[k<<1]) return query(k<<1,l,mid,v);
    return query(k<<1|1,mid+1,r,v-sum[k<<1]);
}
int x[N],y[N];
int vis[N];
int main(){
    int n,m; scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d%d",&x[i],&y[i]);
    for(int i=m+1;i<=m+n;i++) update(1,1,n+m,i,1);
    reverse(x+1,x+1+m);
    reverse(y+1,y+1+m);
    for(int i=m;i>=1;i--){
        int p = query(1,1,n+m,y[i]);
        update(1,1,n+m,p,-1);
        update(1,1,n+m,i,+1);
        if(x[p]==0) x[p] = x[i];
        else if(x[p]!=x[i]) return 0 * printf("-1\n");
    }
    for(int i=m+1;i<=m+n;i++) if(x[i]){
        if(vis[x[i]]) return 0 * printf("-1\n");
        vis[x[i]] = 1;
    }
    int c = 1;
    for(int i=m+1;i<=m+n;i++) if(!x[i]){
        while(vis[c]) c++;
        x[i] = c++;
    }
    for(int i=m+1;i<=m+n;i++) printf("%d%c",x[i]," \n"[i==n+m]);
}

#include "omp.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <random>
#include <bitset>
#include <unordered_set>
#include <cassert>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

const int sze = 1e5 + 10, INF = 1e9 + 10;

struct node
{
	node *left, *right;
	int y, v, cnt, ind;

	node(int ind) : left(0), right(0), y((rand() << 16) ^ rand()), v(0), cnt(1), ind(ind) {};
};

typedef node* treap;
typedef pair<treap, treap> ptt;

int get(treap cur)
{
	return !cur ? 0 : cur->cnt;
}

treap update(treap cur)
{
	cur->cnt = 1 + get(cur->left) + get(cur->right);
	return cur;
}

treap merge(treap L, treap R)
{
	if (!L)
		return R;

	if (!R)
		return L;

	if (L->y > R->y)
	{
		L->right = merge(L->right, R);
		return update(L);
	}
	else
	{
		R->left = merge(L, R->left);
		return update(R);
	}
}

ptt split(treap cur, int x)
{
	if (!cur)
		return { cur, cur };

	int cur_x = get(cur->left);

	if (x >= cur_x)
	{
		ptt ans = split(cur->right, x - cur_x - 1);
		cur->right = ans.first;

		return { update(cur), ans.second };
	}
	else
	{
		ptt ans = split(cur->left, x);
		cur->left = ans.second;

		return { ans.first, update(cur) };
	}
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, m;
	cin >> n >> m;
	treap root = 0;

	vector<int> ans(n);

	for (int i = 0; i < n; ++i)
		root = merge(root, new node(i));

	vector<int> there(n + 1);

	int label = 1;

	for (int i = 0; i < m; ++i)
	{
		int ind, v;
		cin >> v >> ind;
		ind--;

		ptt F1 = split(root, ind);
		ptt F2 = split(F1.first, ind - 1);

		if (!there[v] && !F2.second->v)
		{
			F2.second->v = v;
			there[v] = 1;
		}
		else if (F2.second->v != v)
		{
			label = 0;
		}

		root = merge(merge(F2.second, F2.first), F1.second);
	}

	if (!label)
		cout << "-1\n";
	else
	{
		int cur = 1;

		for (int i = 0; i < n; ++i)
		{
			ptt F1 = split(root, i);
			ptt F2 = split(F1.first, i - 1);

			if (!F2.second->v)
			{
				while (there[cur])
					cur++;

				ans[F2.second->ind] = cur;
				there[cur] = 1;
			}
			else
				ans[F2.second->ind] = F2.second->v;

			root = merge(merge(F2.first, F2.second), F1.second);
		}

		for (int v : ans)
			cout << v << ' ';
	}
	return 0;
}

//============================================================================
// Name        : cf.cpp
// Author      : HX
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>

using namespace std;
#define  N   3111113
#define  M   22222
#define  eps 1e-8
#define  pi  acos(-1.0)
#define  inf 0XFFFFFFFll
#define  mod 1000000007ll
#define  LL  long long
// 同线段树一样，当前节点有lazy标记且信息正确
// 插入节点 root->ch[1]->setc(newNodw(v), 0);
// 初始化 root = build(a, 0, n+2); root->p = null; cur = pool;
// 哨兵节点a[0], a[n+1];
namespace Splay {
	struct Node {
		int size, val;
		Node *p, *ch[2];
		Node() : size(0), val(0) {
			p = ch[0] = ch[1] = NULL;
		}
		void setc(Node *c, int d) {
			ch[d] = c;
			c->p = this;
		}
		bool d() {
			return this == this->p->ch[1];
		}

		void relax();
		void upd() {
			size = 1 + ch[0]->size + ch[1]->size;
		}
	}Tnull, *null = &Tnull;
	Node pool[N], *cur = pool, *root;

	void Node::relax() {
	}

	Node* newNode(int _val = 0) {
		cur->size = 1;
		cur->p = cur->ch[0] = cur->ch[1] = null;
		cur->val = _val;
		return cur++;
	}

	Node* buildtree(int a[], int l, int r) { //[l, r)
		if (l >= r)
			return null;
		int m = (l + r) >> 1;
		Node *ret = newNode(a[m]);
		ret->setc(buildtree(a, l, m), 0);
		ret->setc(buildtree(a, m+1, r), 1);
		ret->upd();
		return ret;
	}

	void rot(Node *t) {
		Node *p = t->p;
		p->relax();
		t->relax();
		int d = t->d();
		p->p->setc(t, p->d());
		p->setc(t->ch[!d], d);
		t->setc(p, !d);
		p->upd();
		if (root == p)
			root = t;
	}

	void splay(Node *t, Node *f = null) {
		while (t->p != f) {
			if (t->p->p == f)
				rot(t);
			else if (t->d() == t->p->d())
				rot(t->p), rot(t);
			else
				rot(t), rot(t);
		}
		t->upd();
	}

	Node* select(int k) {
		for (Node*t = root;;) {
			t->relax();
			int c = t->ch[0]->size + 1;
			if (c == k)
				return t;
			if (c > k)
				t = t->ch[0];
			else
				k -= c, t = t->ch[1];
		}
	}

	void getInterval(int l, int r) { //[l, r)
		Node *L = select(l);
		Node *R = select(r + 1);
		splay(L);
		splay(R, L);
	}
}

using namespace Splay;

int n, m;
int a[N];
int num[N];
// 同线段树一样，当前节点有lazy标记且信息正确
// 插入节点 root->ch[1]->setc(newNodw(v), 0);
// 初始化 root = build(a, 0, n+2); root->p = null; cur = pool;
// 哨兵节点a[0], a[n+1];
int x[N], y[N];
int ans[N];
int flag[N];
int cnt = 0;
void dfs(Node *now) {
	if (now->ch[0] != null)
		dfs(now->ch[0]);
	ans[cnt++] = now->val;
	flag[now->val] = true;
	if (now->ch[1] != null)
		dfs(now->ch[1]);
}

int main() {
	scanf("%d%d", &n, &m);
//	for (int i=1; i<=n+1; i++)
//		a[i] = i;
	a[0] = n + 1;
	a[n+1] = n + 2;
	cur = pool;
	root = buildtree(a, 0, n + 2);
	root->p = null;
	for (int i=0; i<m; i++) {
		scanf("%d%d", &x[m-1-i], &y[m-1-i]);
	}
	for (int i=0; i<m; i++) {
		getInterval(1, 2);
		int val = root->ch[1]->ch[0]->val;
		if (val != 0 && val != x[i]) {
			puts("-1");
			return 0;
		}
//		if (y[i] == 1) {
//			root->ch[1]->ch[0]->val = x[i];
//			continue;
//		}
		root->ch[1]->ch[0] = null;
		splay(root->ch[1]);
		getInterval(y[i], y[i]);
		a[0] = x[i];
		root->ch[1]->setc(newNode(x[i]), 0);
		splay(root->ch[1]->ch[0]);
	}
	dfs(root);
	for (int i=1; i<=n; i++) {
		num[ans[i]]++;
		if (ans[i] != 0 && num[ans[i]] > 1) {
			puts("-1");
			return 0;
		}
	}
	for (int i=1, j=1; i<=n; i++) {
		if (ans[i] == 0) {
			while (flag[j] == true)
				j++;
			ans[i] = j;
			j++;
		}
	}
	for (int i=1; i<=n; i++)
		printf("%d ", ans[i]);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll inf = 1000000000;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct node {
    ll y;
    int val, ssize, numl;
    node *left, *right;

    node(int y0, int ssize0){
        y = y0;
        val = numl = -1;
        left = right = nullptr;
        ssize = ssize0;
    }
};

int k(node *root){
    if(root)return root->ssize;
    else return 0;
}

void upd(node *root){
    root->ssize = k(root->left) + 1 + k(root->right);
    if(root->left)root->numl = root->left->numl;
    else root->numl = root->val;
}

int now2 = 1;

node *create(int kol_vo){
    if(!kol_vo)return nullptr;
    else {
        node *res = new node(now2++, kol_vo);
        kol_vo--;
        int mid = kol_vo/2;
        res->left = create(mid);
        res->right = create(kol_vo-mid);
        return res;
    }
}

pair<node *, node *> split_kth(node *root, int pos){
    if(root == nullptr)return {nullptr, nullptr};
    if(k(root->left) >= pos){
        auto res = split_kth(root->left, pos);
        root->left = res.second;
        upd(root);
        return {res.first, root};
    }
    else {
        auto res = split_kth(root->right, pos - (1 + k(root->left)));
        root->right = res.first;
        upd(root);
        return {root, res.second};
    }
}

node *mmerge(node *root1, node *root2){
    if(root1 == nullptr)return root2;
    if(root2 == nullptr)return root1;
    if(root1->y < root2->y){
        root1->right = mmerge(root1->right, root2);
        upd(root1);
        return root1;
    }
    else {
        root2->left = mmerge(root1, root2->left);
        upd(root2);
        return(root2);
    }
}

void *update_kth(node *root, int pos, int num){
    if(k(root->left) >= pos){
        update_kth(root->left, pos, num);
        upd(root);
    }
    else {
        if(k(root->left) + 1 == pos){
            root->val = num;
            upd(root);
        }
        else {
            update_kth(root->right, pos - (1 + k(root->left)), num);
            upd(root);
        }
    }
}

int m[1000001];
int now = 1;

void prin2(node *root){
    if(root == nullptr)return;
    prin2(root->left);
    cout << root->val << " ";
    prin2(root->right);
}

void prin(node *root){
    if(root == nullptr)return;
    prin(root->left);
    if(root->val != -1){
        cout << root->val << " ";
    }
    else {
        while(m[now])now++;
        cout << now++ << " ";
    }
    prin(root->right);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
/*
    freopen("movetofront.in", "r", stdin);
    freopen("movetofront.out", "w", stdout);
*/
    int kol_vo, ask;
    cin >> kol_vo >> ask;
    node *root = create(kol_vo);
    for(int c=0; c<=1000000; c++)
        m[c] = 0;
    vector<pair<int, int> > dop(ask);
    for(int c=0; c<ask; c++)
        cin >> dop[c].first >> dop[c].second;
    reverse(dop.begin(), dop.end());
    for(int c=0; c<ask; c++){
        int num, pos;
        num = dop[c].first;
        pos = dop[c].second;
        if(root->numl == -1 && m[num]){
            cout << -1;
            return 0;
        }
        if(root->numl == -1){
            update_kth(root, 1, num);
        }
        if(root->numl == num){
            auto res1 = split_kth(root, pos);
            auto res2 = split_kth(res1.first, 1);
            root = mmerge(res2.second, mmerge(res2.first, res1.second));
        }
        else {
            cout << -1;
            return 0;
        }
        m[num] = 1;
       // prin2(root);
       // cout << endl;
    }
    prin(root);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

struct Treap {
    int x, y, size;
    Treap *left, *right;

    Treap(int x_) : x(x_), y(rand() << 16 ^ rand()), size(1), left(nullptr), right(nullptr) {}
};

inline int size(Treap *root) {
    return root ? root->size : 0;
}

inline void update(Treap *root) {
    if (root == nullptr) {
        return;
    }
    root->size = size(root->left) + size(root->right) + 1;
}

pair<Treap *, Treap *> split(Treap *root, int sz) {
    if (root == nullptr) {
        return {nullptr, nullptr};
    }
    Treap *left, *right;
    if (size(root->left) < sz) {
        left = root;
        tie(root->right, right) = split(root->right, sz - size(root->left) - 1);
    } else {
        right = root;
        tie(left, root->left) = split(root->left, sz);
    }
    update(root);
    return {left, right};
}

Treap *merge(Treap *left, Treap *right) {
    if (left == nullptr || right == nullptr) {
        return left ? left : right;
    }
    Treap *root;
    if (left->y > right->y) {
        left->right = merge(left->right, right);
        root = left;
    } else {
        right->left = merge(left, right->left);
        root = right;
    }
    update(root);
    return root;
}

Treap *insert(Treap *root, int x, int i) {
    Treap *left, *right, *mid = new Treap(x);
    tie(left, right) = split(root, i);
    return merge(merge(left, mid), right);
}

const int N = 1000005;
bool us[N];
vector<int> perm;

void recover(Treap *root) {
    if (root == nullptr) {
        return;
    }
    recover(root->left);
    perm.push_back(root->x);
    recover(root->right);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ops(m);
    for (int i = 0; i < m; i++) {
        cin >> ops[i].first >> ops[i].second;
        ops[i].second--;
    }
    reverse(ops.begin(), ops.end());
    Treap *root = nullptr;
    for (int i = 0; i < n; i++) {
        root = insert(root, 0, 0);
    }
    for (const auto &p : ops) {
        int x = p.first, i = p.second;
        Treap *left, *right, *mid;
        tie(left, right) = split(root, 1);
        if (us[x] && left->x != x || left->x && left->x != x) {
            cout << "-1\n";
            return 0;
        }
        us[x] = true;
        left->x = x;
        tie(mid, right) = split(right, i);
        root = merge(merge(mid, left), right);
    }
    recover(root);
    for (int i = 0, j = 1; i < n; i++) {
        if (perm[i] == 0) {
            while (us[j]) {
                j++;
            }
            perm[i] = j++;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << perm[i] << " ";
    }
    cout << "\n";
}

//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 2e6 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int pos[maxN], seg[4 * maxN];
int n, q, P[maxN], cnt[maxN];
vector <int> vec;

void put(int p, int x, int id = 1, int s = 0, int e = n + q){
	if (e - s <= 1){
		seg[id] = x;
		return;
	}
	int md = (s + e) >> 1;
	if (p < md)
		put(p, x, lid, s, md);
	else
		put(p, x, rid, md, e);
	seg[id] = seg[lid] + seg[rid];
	return;
}

int fetch(int p, int id = 1, int s = 0, int e = n + q){
	if (e - s <= 1)
		return s;
	int md = (s + e) >> 1;
	if (seg[lid] <= p)
		return fetch(p - seg[lid], rid, md, e);
	else
		return fetch(p, lid, s, md);
}

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++){
		put(i + q, 1);
		pos[i + q] = i;
	}
	bool flag = true;
	for (int i = q; flag && i > 0; i--){
		int x, y; scanf("%d%d", &x, &y); y--;
		int tmp = fetch(y);
		put(tmp, 0);
		if (P[pos[tmp]] != 0 && P[pos[tmp]] != x)
			flag = false;
		put(i - 1, 1);
		P[pos[tmp]] = x;
		pos[i - 1] = pos[tmp];
	}
	for (int i = 0; i < n; i++)
		cnt[P[i]]++;
	for (int i = n; i > 0; i--){
		if (cnt[i] > 1)
			flag = false;
		if (cnt[i] == 0)
			vec.push_back(i);
	}
	if (!flag)
		return printf("-1\n"), 0;
	for (int i = 0; i < n; i++){
		if (P[i])
			printf("%d ", P[i]);
		else{
			printf("%d ", vec.back());
			vec.pop_back();
		}
	}
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (((b+s) < 0 )? (b+s)/2-1:(b+s)/2)
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf

using namespace std;

inline int read() {
	int res = 0 ;int neg ;
	while(true){char ch = getchar();if(ch>='0' && ch<='9' || ch=='-'){if(ch=='-') neg = -1;else neg = 1 , res = ch-'0';break;} }
	while(true){char ch = getchar();if(ch>='0' && ch<='9') res*=10 , res+=ch-'0';else break;}
	return res*neg;
}

const int maxn = 1000020;
const int maxm = 1020;
const int MOd = 1e9+7;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;

struct treap {
	int x, y;
	treap *l, *r;
	int sz;
	treap(int x);
}*root,*root2,*null;

int a, b, ans[maxn];
bool used[maxn];

treap :: treap( int _x=0 ) {
	x = _x; sz = 1;
	y = rand();
	l = r = null;
}

void bit(  ) {
	printf("-1\n");
	exit(0);
}

void relax( treap *root ) {
	if( root == null ) return;
	root->sz = 1 + root->l->sz + root->r->sz;
}

void split( treap *root, treap *&l, treap *&r, int find ) {
	if( root == null ) {
		l = r = null;
		return;
	}
	if( root->l->sz+1 <= find ) {
		split( root->r, l, r, find-root->l->sz-1 );
		root->r = l;
		l = root;
		relax( l );
	} else {
		split( root->l, l, r, find );
		root->l = r;
		r = root;
		relax( r );
	}
}

treap *merge( treap *l, treap *r ) {
	if( l == null ) return r;
	if( r == null ) return l;
	if( l->y > r->y ) {
		l->r = merge( l->r, r );
		relax( l );
		return l;
	} else {
		r->l = merge( l, r->l );
		relax( r );
		return r;
	}
}

int main() {

	//~ freopen("asd.in","r",stdin);

	null = new treap();
	null->x = null->y = null->sz = 0;
	null->l = null->r = null;
	root = null;
	root2 = null;

	scanf("%d %d",&a,&b);

	for(int i=1;i<=a;i++) root2 = merge( root2, new treap( i ) );

	for(int i=1,x,y;i<=b;i++) {
		scanf("%d %d",&x,&y);
		if( y <= root->sz ) {
			treap *t1, *t2;
			split( root, root, t1, y-1 );
			split( t1, t1, t2, 1 );
			//~ printf("asdasd\n");
			if( t1->x != x ) bit();
			//~ printf("asdasd\n");
			root = merge( root, t2 );
			root = merge( t1, root );
		} else {
			//~ printf("asasd %d\n",x);
			if( used[x] ) bit();

			treap *t1, *t2;
			split( root2, root2, t1, y-root->sz-1 );
			split( t1, t1, t2, 1 );
			//~ printf("%d %d %d\n",root2->sz,t1->sz,t1->x);
			if( ans[t1->x] ) bit();
			//~ printf("%d %d %d\n",root2->sz,t1->sz,t1->x);
			ans[t1->x] = x;
			used[x] = 1;
			root2 = merge( root2, t2 );
			root = merge( new treap( x ), root );
		}
	}

	for(int i=1,j=1;i<=a;i++) {
		if( ans[i] ) printf("%d ",ans[i]);
		else {
			//~ printf("asdad %d %d\n",j,used[j]);
			while( j <= a && used[j] ) j++;
			used[j] = 1;
			printf("%d ",j);
		}
	}
	printf("\n");
	return 0;
}

#include <stdio.h>
#include <algorithm>
using namespace std;
struct Tree
{
	int v, sz;
	Tree *l, *r, *p;
};
int n, m, mc, tl, t[1000000], ans[1000000];
bool cn[1000000];
Tree memory[1000001], *tree;
void Update(Tree *x)
{
	x->sz = 1;
	if(x->l)
		x->sz += x->l->sz;
	if(x->r)
		x->sz += x->r->sz;
}
void LeftRotate(Tree *x, Tree *&root)
{
	Tree *y = x->r;
	if(x == root)
		root = y;
	else if(x == x->p->l)
		x->p->l = y;
	else
		x->p->r = y;
	y->p = x->p;
	x->p = y;
	if(y->l)
		y->l->p = x;
	x->r = y->l;
	y->l = x;
	Update(x);
	Update(y);
}
void RightRotate(Tree *x, Tree *&root)
{
	Tree *y = x->l;
	if(x == root)
		root = y;
	else if(x == x->p->l)
		x->p->l = y;
	else
		x->p->r = y;
	y->p = x->p;
	x->p = y;
	if(y->r)
		y->r->p = x;
	x->l = y->r;
	y->r = x;
	Update(x);
	Update(y);
}
void Rotate(Tree *x, Tree *&root)
{
	if(x == x->p->l)
		RightRotate(x->p, root);
	else
		LeftRotate(x->p, root);
}
void Splay(Tree *x, Tree *&root)
{
	while(x != root)
	{
		if(x->p == root)
			Rotate(x, root);
		else if(x == x->p->l && x->p == x->p->p->l || x == x->p->r && x->p == x->p->p->r)
			Rotate(x->p, root), Rotate(x, root);
		else
			Rotate(x, root), Rotate(x, root);
	}
}
void SplayRank(Tree *&root, int rank)
{
	Tree *x = root;
	while(x)
	{
		int size = x->l ? x->l->sz : 0;
		if(rank == size)
			break;
		else if(rank > size)
			rank -= size + 1, x = x->r;
		else
			x = x->l;
	}
	Splay(x, root);
}
int main()
{
	scanf("%d%d", &n, &m);
	tree = &memory[mc++];
	tree->sz = 1;
	for(int i = n - 1; i >= 0; i--)
	{
		Tree *tmp = &memory[mc++];
		tmp->v = i;
		tmp->sz = tree->sz + 1;
		tmp->r = tree;
		tree->p = tmp;
		tree = tmp;
	}
	for(int i = 0; i < n; i++)
		ans[i] = -1;
	bool ok = true;
	for(int i = 0, x, y; i < m; i++)
	{
		scanf("%d%d", &x, &y), x--, y--;
		SplayRank(tree, y + 1);
		if(tree->l->sz != y + 1)
			int stop = 0;
		SplayRank(tree->l, y);
		if(tree->l->r)
			int stop = 0;
		if(ans[tree->l->v] != -1 && ans[tree->l->v] != x)
		{
			ok = false;
			break;
		}
		ans[tree->l->v] = x;
		swap(tree->l->l, tree->l->r);
	}
	for(int i = 0; i < n && ok; i++)
	{
		if(ans[i] != -1)
		{
			if(cn[ans[i]])
				ok = false;
			cn[ans[i]] = true;
		}
	}
	if(!ok)
		printf("-1");
	else
	{
		for(int i = 0; i < n; i++)
		{
			if(!cn[i])
				t[tl++] = i;
		}
		for(int i = 0, j = 0; i < n; i++)
			printf("%d ", ans[i] == -1 ? t[j++] + 1 : ans[i] + 1);
	}
	getchar(); getchar();
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define type(x) __typeof(x.begin())

#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define endl '\n'

#define EXIT { printf("-1\n"); exit(0); }

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e6 + 5;

int h[N], bef, n, m, w[N], t, x, y;
pii xx, ST[N << 2];

pii merge(pii x, pii y) { return pair < int , int > (x.st + y.st, x.nd + y.nd); }

pii init(int k, int bas, int son) {
	if(bas == son) {
		if(bas > m) ST[k] = mp(bas-m, 1);
		else ST[k] = mp(0, 0);
		return ST[k];
	}
	return ST[k] = merge(init(sol, bas, orta), init(sag, orta+1, son));
}

pii query(int k, int bas, int son, int x) {
	if(bas == son) return mp(bas, ST[k].st);
	if(ST[sol].nd >= x)
		return query(sol, bas, orta, x);
	return query(sag, orta+1, son, x - ST[sol].nd);
}

pii update(int k, int bas, int son, int x, int t) {
	if(bas > x || son < x) return ST[k];
	if(bas == son) {
		if(t == 0) ST[k] = mp(0, 0);
		else ST[k] = mp(t, 1);
		return ST[k];
	}
	return ST[k] = merge(update(sol, bas, orta, x, t), update(sag, orta+1, son, x, t));
}

int main() {

	scanf("%d %d", &n, &m);

	init(1, 1, n + m);

	bef = m+1;

	FOR(i, 1, m) {
		scanf("%d %d", &y, &x);
		xx = query(1, 1, n + m, x);
		if(w[xx.nd] && w[xx.nd] != y) EXIT;
		if(!w[xx.nd] && h[y]) EXIT;
		w[xx.nd] = y;
		h[y] = 1;
		update(1, 1, n + m, xx.st, 0);
		update(1, 1, n + m, --bef, xx.nd);
	}
	int t = 1;
	FOR(i, 1, n) {
		if(w[i]) printf("%d ",w[i]);
		else {
			while(h[t]) t++;
			h[t] = 1;
			printf("%d ",t);
		}
	} cout << endl;

	return 0;
}

//#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
template<class T> inline T sqr(T x) { return x * x; }
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef pair<LL, LL> PLL;
typedef pair<LL, int> PLI;
typedef pair<LD, LD> PDD;
#define MP make_pair
#define PB push_back
#define sz(x) ((int)(x).size())
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define FOR(i,n) for(int i=0;i<(n);++i)
#define forIt(mp,it) for(__typeof(mp.begin()) it = mp.begin();it!=mp.end();it++)
const int INF = 0x3fffffff;
const double PI = acos(-1.0);

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define lowbit(u) (u&(-u))

using namespace std;

class Treap{
public:
#define MAXN 100005
	struct Node{
		Node *ch[2];
		int r,sz;//r是随机优先级，sz是子树的结点个数
		bool operator<(const Node &nd) const{
			return r<nd.r;
		}
		int cmp(int x){
			if(x==v) return -1;
			return x>v;
		}

		//维护的结点信息
		LL v,x;
		int pos;

		void init(LL _v,int _x,int _pos){
			v = _v;
			pos = _pos;
			x = _x;
			sz = 1;
			ch[0] = ch[1] = NULL;
			r = rand();
		}
	} nd[MAXN];

	int ndcnt;
	void init(){
		ndcnt = 0;
	}

	Node *newNode(LL v,int x,int pos){
		nd[ndcnt].init(v,x,pos);
		return &nd[ndcnt++];
	}

	void push_Up(Node *rt){
		if(rt==NULL) return;
		rt->sz = 1;
		if(rt->ch[0]!=NULL) rt->sz+=rt->ch[0]->sz;
		if(rt->ch[1]!=NULL) rt->sz+=rt->ch[1]->sz;
	}

	void rotate(Node *&o,int d){
		Node *k = o->ch[d^1];
		o->ch[d^1] = k->ch[d];
		k->ch[d] = o;
		push_Up(o);
		push_Up(k);
		o = k;
	}

	//插入值为val的结点
	void insertVal(Node *&o,LL val,int x,int pos){
		if(o==NULL) o = newNode(val,x,pos);
		else{
			int d = (val<o->v?0:1);
			insertVal(o->ch[d],val,x,pos);
			if(o->ch[d]>o) rotate(o,d^1);
		}
		push_Up(o);
	}

	//删除值为val的结点，只删除一个
	void removeVal(Node *&o,int val){
		if(o==NULL) return;
		int d = o->cmp(val);
		if(d==-1){
			if(o->ch[0]!=NULL&&o->ch[1]!=NULL){
				int d2 = (o->ch[0]>o->ch[1]?1:0);
				rotate(o,d2);removeVal(o->ch[d2],val);
			}else{
				if(o->ch[0]==NULL) o = o->ch[1];
				else o = o->ch[0];
			}
		}else removeVal(o->ch[d],val);
		if(o!=NULL) push_Up(o);
	}

	//返回比结点值比val小的结点个数
	int getRank(Node *o,int val){
		if(o==NULL) return 0;
		int d = o->cmp(val);
		if(d==1){
			int lsz = (o->ch[0]==NULL?0:o->ch[0]->sz);
			return lsz+1+getRank(o->ch[1],val);
		}else return getRank(o->ch[0],val);
	}

	//返回第k大的结点
	Node* Kth(Node *o,int k){
		if(o==NULL||k<=0||k>o->sz) return NULL;
		int s = (o->ch[0]==NULL?0:o->ch[0]->sz);
		if(k==s+1) return o;
		else if(k<=s) return Kth(o->ch[0],k);
		else return Kth(o->ch[1],k-s-1);
	}

	int vis[1000005];
	int ans[1000005];
	int idx;

	void dfs(Node *rt){
		if(rt==NULL) return;
		dfs(rt->ch[0]);
		if(rt->x==-1){
			while(vis[idx]) idx++;
			vis[idx] = 1;
			rt->x = idx;
		}
		ans[rt->pos] = rt->x;
		dfs(rt->ch[1]);
	}

} treap;

int main(void){
#ifndef ONLINE_JUDGE
	freopen("/Users/mac/Desktop/data.in","r",stdin);
#endif
	srand(time(NULL));
	int n,m;
	scanf("%d %d",&n,&m);
	treap.init();
	Treap::Node *root = NULL;
	for(int i = 1;i<=n;i++) treap.insertVal(root,i,-1,i);
	LL sub = INF;
	memset(treap.vis,0,sizeof(treap.vis));
	treap.idx = 1;
	while(m--){
		int x,y;
		scanf("%d %d",&x,&y);
		Treap::Node *cur = treap.Kth(root,y);
		if(cur->x==-1||cur->x==x){
			if(cur->x==-1&&treap.vis[x]){
				puts("-1");
				return 0;
			}
			treap.removeVal(root,cur->v);
			treap.vis[x] = 1;
			treap.insertVal(root,cur->v-sub,x,cur->pos);
		}else{
			puts("-1");
			return 0;
		}
		sub+=INF;
	}
	treap.dfs(root);
	for(int i = 1;i<=n;i++) printf("%d ",treap.ans[i]);
	puts("");
	return 0;
}

#ifndef _DEBUG
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#ifdef _DEBUG
ifstream cin("input.txt");
ofstream cout("output.txt");
#endif
typedef long long LL;
//typedef long double LL;
double eps = 1e-9;
const LL INF = 1e9;
LL mod = 1e9 + 7;

struct node
{
	node* left;
	node* right;
	LL key;
	LL w;
	LL cnt;
	LL prior;
	LL num;
	node(LL k, LL p, LL wei = 0, LL num1 = 0)
	{
		key = k;
		prior = p;
		w = wei;
		left = nullptr;
		right = nullptr;
		cnt = 0;
		num = num1;
	}
};
typedef node* pnode;
pnode tree;
LL cnt(pnode t)
{
	return t ? t->cnt:0;
}
void update_cnt(pnode t)
{
	if(t)
		t->cnt = 1 + cnt(t->left) + cnt(t->right);
}
void split(pnode tree, LL key, pnode& left, pnode& right,LL superkey = 0)
{
	if(tree == nullptr)
	{
		left = right = nullptr;
	}
	else
	{
		LL s = 1 + superkey + cnt(tree -> left);
		if(key <= s)
		{
			split(tree -> left, key, left, tree->left, superkey);
			right = tree;
		}
		else
		{
			split(tree->right, key, tree->right, right, s);
			left = tree;
		}
	}
	update_cnt(tree);
}

void insert(pnode& tree, pnode elem)
{
	if(tree == nullptr)
		tree = elem;
	else if(tree -> prior < elem->prior)
		split(tree, elem->key, elem->left, elem->right), tree = elem;
	else
		insert(elem->key < tree->key? tree->left:tree->right ,elem);
	update_cnt(tree);
}
void merge(pnode& tree, pnode & l, pnode& r)
{
	if(!r || !l)
	{
		tree = l? l:r;
	}
	else if(l->prior > r->prior)
		merge(l->right, l->right, r), tree = l;
	else
		merge(r->left, l, r->left), tree = r;
	update_cnt(tree);
}
void find(pnode& res, pnode t, LL key, LL  superkey = 0)
{
	LL s = 1 + superkey + cnt(t->left);
	t->w = s;
	if(!t)
	{
		res = t;
		return;
	}
	if(key < t->key)
	{
		find(res, t->left, key, superkey);
	}
	else
		if(key > t->key)
		{
			find(res, t->right, key, s);
		}
		else
		{
			res = t;
			return;
		}
}
void erase(pnode& t, int key)
{
	if(!t)
		return;
	if(t->key == key)
		merge(t, t->left, t->right);
	else
		erase(key < t->key ? t->left : t->right, key);
	update_cnt(t);
}
void findpos(pnode& res, pnode t, LL key, LL superkey = 0)
{

	LL s = 1 + superkey + cnt(t->left);
	t->w = s;
	if(!t)
	{
		res = t;
		return;
	}
	if(key < s)
	{
		findpos(res, t->left, key, superkey);
	}
	else
		if(key > s)
		{
			findpos(res, t->right, key, s);
		}
		else
		{
			res = t;
			return;
		}
}
set<LL> nums;
vector<LL> res;
void printans(pnode& tree)
{
	if(!tree)
	{
		return;
	}
	printans(tree->left);
	if(tree->key == -1)
	{
		tree->key = *nums.begin();
		nums.erase(nums.begin());
	}
	res[tree->num] = (tree->key);
	printans(tree->right);
}
int main()
{
	ios::sync_with_stdio(false);
	LL n, m;
	cin>>n>>m;
	for(int i = 0; i<n; i++)
	{
		insert(tree, new node(-1, rand(), 0, i));
		nums.insert(i+1);
	}
	vector<pair<LL, LL> > a;
	a.resize(m);
	LL x,y;
	for(int i = 0; i<m; i++)
	{
		cin>>x>>y;
		a[i] = make_pair(x, y);
	}
	pnode pos = nullptr, elem = nullptr;
	pnode l = nullptr, mid = nullptr, r = nullptr;
	for(int i = 0; i<a.size(); i++)
	{
		findpos(pos, tree, a[i].second);
		if(nums.find(a[i].first) != nums.end())
		{
			if(pos->key == -1)
			{
				split(tree, pos->w, l, r);
				split(r, 2, mid, r);
				mid->key = a[i].first;
				tree = nullptr;
				merge(tree, l, r);
				merge(tree, mid, tree);
			}
			else
			{
				cout<<-1;
				return 0;
			}
		}
		else
		{
			if(pos->key == a[i].first)
			{
				split(tree, pos->w, l, r);
				split(r, 2, mid, r);
				//mid->key = a[i].first;
				tree = nullptr;
				merge(tree, l, r);
				merge(tree, mid, tree);
			}
			else
			{
				cout<<-1;
				return 0;
			}
		}
		nums.erase(a[i].first);
	}
	res.resize(n);
	printans(tree);
	for(int i = 0; i<res.size(); i++)
	{
		cout<<res[i]<<' ';
	}
	return 0;
}

// Mon Feb 01 2016 23:59:20 GMT+0300 (MSK)

//Template
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
    static int r, sign;
    static char c;
    r = 0, sign = 1;
    do c = getchar(); while (c != '-' && (c < '0' || c > '9'));
    if (c == '-') sign = -1, c = getchar();
    while (c >= '0' && c <= '9') r = r * 10 + (int)(c - '0'), c = getchar();
    return sign * r;
}

template <typename T>
inline void print(T *a, int n) {
    for (int i = 1; i < n; ++i) cout << a[i] << " ";
    cout << a[n] << endl;
}
#define PRINT(_l, _r, _s, _t) { cout << #_l #_s "~" #_t #_r ": "; for (int _i = _s; _i != _t; ++_i) cout << _l _i _r << " "; cout << endl; }

#define N 1000000

struct oper {
    int l, r, n, ans;
} q[N + 1];

inline bool cmp1(const oper &x, const oper &y) {
    return x.l < y.l;
}

inline bool cmp2(const oper &x, const oper &y) {
    return x.n < y.n;
}

int n, m, x[N + 1], y[N + 1], p[N + 1], pos[N + 1], seq[N + 1], nex[N + 1];

struct BIT {
    int arr[N + 1], n;

    inline void modify(int x, int v) {
        for (; x <= n; x += x & -x) arr[x] += v;
    }

    inline int query(int x) {
        int r = 0;
        for (; x > 0; x -= x & -x) r += arr[x];
        return r;
    }
} T;

int tree[N * 5];

inline void update(int x) {
    tree[x] = tree[x << 1] + tree[x << 1 | 1];
}

void build(int x, int l, int r) {
    if (l == r) {
        tree[x] = 1;
        return ;
    }
    int mid = l + r >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
    update(x);
}

void modify(int x, int l, int r, int p) {
    if (l == r) {
        tree[x] = 0;
        return ;
    }
    int mid = l + r >> 1;
    if (p <= mid) modify(x << 1, l, mid, p);
    else modify(x << 1 | 1, mid + 1, r, p);
    update(x);
}

int query(int x, int l, int r, int k) {
    if (l == r) return l;
    int mid = l + r >> 1;
    if (tree[x << 1] >= k) return query(x << 1, l, mid, k);
    else return query(x << 1 | 1, mid + 1, r, k - tree[x << 1]);
}

int main(int argc, char *argv[]) {
#ifdef KANARI
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i)
        scanf("%d%d", x + i, y + i);
    for (int i = 1; i <= m; ++i) {
        p[i] = pos[x[i]];
        pos[x[i]] = i;
        q[i].l = p[i] + 1, q[i].r = i, q[i].n = i;
    }
    for (int i = 1; i <= m; ++i) nex[p[i]] = i;

    sort(q + 1, q + m + 1, cmp1);
    T.n = m;
    for (int i = 1; i <= m; ++i)
        if (p[i] == 0) T.modify(i, 1);
    for (int i = 1, j = 1; i <= m; ++i) {
        while (j <= m && q[j].l == i) {
            q[j].ans = T.query(q[j].r);
            ++j;
        }
        if (nex[i] != 0) T.modify(nex[i], 1);
        T.modify(i, -1);
    }

    build(1, 1, n);
    sort(q + 1, q + m + 1, cmp2);
//  P.n = n;
//  for (int i = 1; i <= n; ++i) P.modify(i, 1);
    for (int i = 1; i <= n; ++i) pos[i] = 0;
    bool ok = true;
    int cnt = 0;
    for (int i = 1; i <= m; ++i) {
        if ((pos[x[i]] != 0 || y[i] < cnt) && y[i] != q[i].ans) ok = false;
//      if (pos[x[i]] != 0 && y[i] != q[i].ans) ok = false;
//      if ()
        if (pos[x[i]] == 0) {
            ++cnt;
//          if (y[i] >= i) {
                pos[x[i]] = query(1, 1, n, y[i] - cnt + 1);
                modify(1, 1, n, pos[x[i]]);
//          } else printf("WTF? %d\n", i);
//          }
        }
//      if (y[i] >= i) modify(1, 1, n, query(1, 1, n, y[i] - i + 1));
//      for (int j = 1; j <= n; ++j) printf("%d ", P.query(j));
//      printf("\n");
    }
    if (!ok) printf("-1\n");
    else {
//      print(pos, n);
        for (int i = 1; i <= n; ++i)
            if (pos[i] != 0) seq[pos[i]] = i;
        for (int i = 1, j = 1; i <= n; ++i)
            if (seq[i] == 0) {
                while (j <= n && pos[j] != 0) ++j;
                seq[i] = j++;
            }
        for (int i = 1; i < n; ++i) printf("%d ", seq[i]);
        printf("%d\n", seq[n]);
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}

//Template
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
    static int r, sign;
    static char c;
    r = 0, sign = 1;
    do c = getchar(); while (c != '-' && (c < '0' || c > '9'));
    if (c == '-') sign = -1, c = getchar();
    while (c >= '0' && c <= '9') r = r * 10 + (int)(c - '0'), c = getchar();
    return sign * r;
}

template <typename T>
inline void print(T *a, int n) {
    for (int i = 1; i < n; ++i) cout << a[i] << " ";
    cout << a[n] << endl;
}
#define PRINT(_l, _r, _s, _t) { cout << #_l #_s "~" #_t #_r ": "; for (int _i = _s; _i != _t; ++_i) cout << _l _i _r << " "; cout << endl; }

#define N 1000000

struct oper {
    int l, r, n, ans;
} q[N + 1];

inline bool cmp1(const oper &x, const oper &y) {
    return x.l < y.l;
}

inline bool cmp2(const oper &x, const oper &y) {
    return x.n < y.n;
}

int n, m, x[N + 1], y[N + 1], p[N + 1], pos[N + 1], seq[N + 1], nex[N + 1];

struct BIT {
    int arr[N + 1], n;

    inline void modify(int x, int v) {
        for (; x <= n; x += x & -x) arr[x] += v;
    }

    inline int query(int x) {
        int r = 0;
        for (; x > 0; x -= x & -x) r += arr[x];
        return r;
    }
} T;

int tree[N * 5];

inline void update(int x) {
    tree[x] = tree[x << 1] + tree[x << 1 | 1];
}

void build(int x, int l, int r) {
    if (l == r) {
        tree[x] = 1;
        return ;
    }
    int mid = l + r >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
    update(x);
}

void modify(int x, int l, int r, int p) {
    if (l == r) {
        tree[x] = 0;
        return ;
    }
    int mid = l + r >> 1;
    if (p <= mid) modify(x << 1, l, mid, p);
    else modify(x << 1 | 1, mid + 1, r, p);
    update(x);
}

int query(int x, int l, int r, int k) {
    if (l == r) return l;
    int mid = l + r >> 1;
    if (tree[x << 1] >= k) return query(x << 1, l, mid, k);
    else return query(x << 1 | 1, mid + 1, r, k - tree[x << 1]);
}

int main(int argc, char *argv[]) {
#ifdef KANARI
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; ++i)
        scanf("%d%d", x + i, y + i);
    for (int i = 1; i <= m; ++i) {
        p[i] = pos[x[i]];
        pos[x[i]] = i;
        q[i].l = p[i] + 1, q[i].r = i, q[i].n = i;
    }
    for (int i = 1; i <= m; ++i) nex[p[i]] = i;

    sort(q + 1, q + m + 1, cmp1);
    T.n = m;
    for (int i = 1; i <= m; ++i)
        if (p[i] == 0) T.modify(i, 1);
    for (int i = 1, j = 1; i <= m; ++i) {
        while (j <= m && q[j].l == i) {
            q[j].ans = T.query(q[j].r);
            ++j;
        }
        if (nex[i] != 0) T.modify(nex[i], 1);
        T.modify(i, -1);
    }

    build(1, 1, n);
    sort(q + 1, q + m + 1, cmp2);
//  P.n = n;
//  for (int i = 1; i <= n; ++i) P.modify(i, 1);
    for (int i = 1; i <= n; ++i) pos[i] = 0;
    bool ok = true;
    int cnt = 0;
    for (int i = 1; i <= m; ++i) {
        if ((pos[x[i]] != 0 || y[i] < i) && y[i] != q[i].ans) ok = false;
//      if (pos[x[i]] != 0 && y[i] != q[i].ans) ok = false;
//      if ()
        if (pos[x[i]] == 0) {
            ++cnt;
//          if (y[i] >= i) {
                pos[x[i]] = query(1, 1, n, y[i] - cnt + 1);
                modify(1, 1, n, pos[x[i]]);
//          } else printf("WTF? %d\n", i);
//          }
        }
//      if (y[i] >= i) modify(1, 1, n, query(1, 1, n, y[i] - i + 1));
//      for (int j = 1; j <= n; ++j) printf("%d ", P.query(j));
//      printf("\n");
    }
    if (!ok) printf("-1\n");
    else {
//      print(pos, n);
        for (int i = 1; i <= n; ++i)
            if (pos[i] != 0) seq[pos[i]] = i;
        for (int i = 1, j = 1; i <= n; ++i)
            if (seq[i] == 0) {
                while (j <= n && pos[j] != 0) ++j;
                seq[i] = j++;
            }
        for (int i = 1; i < n; ++i) printf("%d ", seq[i]);
        printf("%d\n", seq[n]);
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}

// I love meowmur
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define pf push_front
#define popb pop_back
#define pop_front popf
#define sz(a) ll(a.size())
#define all(a) ((a).begin(), (a).end())
#define die(cond) if (cond) for (;;) {}
#define ft first
#define sd second
#define hash_set unordered_set
#define hash_map unordered_map
#define heap priority_queue
#define mineq(a, b) (a)=((a)<(b))?(a):(b)
#define maxeq(a, b) (a)=((a)>(b))?(a):(b)
#define fast ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0)
#define endl "\n"
#define y1 y_1
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
const ll inf = numeric_limits<ll>::infinity();
const ld pi = acos(-1);
const ld eps = 1e-9;

inline void solve(), read();

int main() {
	read();
	solve();
	return 0;
}

struct vertex {
	ll val = -1, prior = rand();
	ll l = -1, r = -1;
	ll sz = 1;
};

struct treap {
	vector<vertex> t;
	treap() {}
	inline ll newv(vertex v) {
		return t.pb(v), sz(t) - 1;
	}
	ll getsz(ll v) {
		if (v == -1) {
			return 0;
		}
		return t[v].sz;
	}
	void upd(ll v) {
		if (v == -1) {
			return;
		}
		t[v].sz = getsz(t[v].l) + getsz(t[v].r) + 1;
	}
	pll split(ll v, ll k) {
		if (v == -1) {
			return { -1, -1 };
		}
		ll l = getsz(t[v].l);
		pll p;
		if (l < k) {
			p = split(t[v].r, k - l - 1);
			t[v].r = p.ft;
			p.ft = v;
		} else {
			p = split(t[v].l, k);
			t[v].l = p.sd;
			p.sd = v;
		}
		upd(v);
		return p;
	}
	ll merge(ll f, ll s) {
		if (f == -1) {
			return s;
		}
		if (s == -1) {
			return f;
		}
		if (t[f].prior > t[s].prior) {
			t[f].r = merge(t[f].r, s);
			upd(f);
			return f;
		} else {
			t[s].l = merge(f, t[s].l);
			upd(s);
			return s;
		}
	}
	ll push_back(ll root, ll val) {
		vertex v; v.val = val;
		root = merge(root, newv(v));
		return root;
	}
	ll push_front(ll root, ll val) {
		vertex v; v.val = val;
		root = merge(newv(v), root);
		return root;
	}
	ll add(ll root, ll ind, ll& val) {
		ll a, b, c;
		tie(a, b) = split(root, ind);
		tie(b, c) = split(b, 0);
		vertex v; v.val = val;
		root = merge(merge(a, newv(v)), c);
		return root;
	}
	ll del(ll root, ll ind, ll& val) {
		ll a, b, c;
		tie(a, b) = split(root, ind);
		tie(b, c) = split(b, 1);
		val = t[b].val;
		root = merge(a, c);
		return root;
	}
	ll move(ll root, ll from, ll to) {
		ll val = 0;
		root = del(root, from, val);
		root = add(root, to, val);
		return root;
	}
	ll equ(ll root, ll ind) {
		ll a, b, c;
		tie(a, b) = split(root, ind);
		tie(b, c) = split(b, 1);
		ll ans = t[b].val;
		merge(merge(a, b), c);
		return ans;
	}
	void assign(ll root, ll ind, ll val) {
		ll a, b, c;
		tie(a, b) = split(root, ind);
		tie(b, c) = split(b, 1);
		t[b].val = val;
		merge(merge(a, b), c);
	}
	void print(ll v) {
		if (v == -1) {
			return;
		}
		print(t[v].l);
		cout << t[v].val << " ";
		print(t[v].r);
	}
};

void test(ll n) {
	treap t;
	ll root = -1;
	for (ll i = 0; i < n; i++) {
		root = t.pf(root, i);
		t.print(root); cout << endl;
	}
	for (ll i = 0; i < n; i++) {
		ll a, b;
		tie(a, b) = t.split(root, i);
	//	t.print(a); cout << "| "; t.print(b); cout << endl;
		t.merge(a, b);
	}
	for (ll i = 0; i < n - 1; i++) {
		ll val = 0;
	//	root = t.del(root, 1, val);
	//	t.print(root); cout << endl;
	}
	for (ll i = 0; i < n; i++) {
		t.assign(root, i, 1);
	//	t.print(root); cout << endl;
	}
	for (ll i = 0; i < n; i++) {
		cout << t.equ(root, i) << endl;
	}
}

ll n, m;
treap tr;
ll root = -1;
vll vs, pos;

inline void solve() {
	for (ll i = 0; i < n; i++) {
		root = tr.pb(root, -1);
	}
	for (ll i = 0; i < m; i++) {
		tr.assign(root, pos[i], vs[i]);
		root = tr.move(root, pos[i], 0);
	}
	for (ll i = 0; i < m; i++) {
		root = tr.move(root, 0, pos[i]);
	}
	for (ll i = 0; i < m; i++) {
		if (tr.equ(root, pos[i]) != vs[i]) {
			cout << -1 << endl;
			return;
		}
		root = tr.move(root, pos[i], 0);
	}
	for (ll i = 0; i < m; i++) {
		root = tr.move(root, 0, pos[i]);
	}
	sll q;
	for (ll i = 1; i <= n; i++) {
		q.insert(i);
	}
	for (ll x : vs) {
		q.erase(x);
	}
	vll ans;
	for (ll i = 0; i < n; i++) {
		ll val = tr.equ(root, i);
		if (val == -1) {
			if (q.empty()) {
				cout << -1 << endl;
				return;
			}
			val = *q.begin();
			q.erase(q.begin());
		}
		ans.pb(val);
	}
	set<ll> s;
	for (ll x : ans) {
		s.insert(x);
	}
	if (sz(s) != sz(ans)) {
		cout << -1 << endl;
		return;
	}
	for (ll x : ans) {
		cout << x << " ";
	}
}

inline void read() {
	cin >> n >> m;
	vs.resize(m), pos.resize(m);
	for (ll i = 0; i < m; i++) {
		cin >> vs[i] >> pos[i];
		--pos[i];
	}
}

#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:167777216")
#include <cmath>
#include <math.h>
#include <complex>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>

#include <unordered_map>
#include <stack>
#include <time.h>
#include <fstream>
#include <queue>
using namespace std;

#define pb push_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second

#define all(x) x.begin(), x.end()
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define M_PI       3.14159265358979323846
#define PI       3.14159265358979323846
typedef long long ll;
typedef  unsigned long long ull;
typedef  long double ld;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef int huint;
const ll Mll = 1000000000000000000;
const ll Mint = 1000000000;

ll mod = 1000000007;

struct treap
{
    treap *l{ nullptr }, *r{ nullptr };
    int k, y, x;
    treap()
    {
        x = 0, y = 0, k = 0;
        r = l = nullptr;
    }
    treap(ll x1, ll y1)
    {
        x = x1, y = y1;
    }
    void calc()
    {
        if (this == nullptr) return;
        k = 1;
        if (r != nullptr) k += r->k;
        if (l != nullptr) k += l->k;
    }
};
void merge(treap* &T, treap* L, treap* R)
{
    if (L == nullptr)
    {
        T = R; T->calc();
        return;
    }
    if (R == nullptr)
    {
        T = L; T->calc();
        return;
    }
    if (L->y > R->y)
    {
        merge(L->r, L->r, R);
        T = L;
    }
    else
    {
        merge(R->l, L, R->l);
        T = R;
    }
    T->calc();
}
void split(treap* T, treap* &L, treap* &R, int k)
{
    if (T == nullptr)
    {
        L = R = nullptr;
        return;
    }
    int kl = 0;
    if (T->l != nullptr) kl = T->l->k;
    if (kl >= k)
    {
        split(T->l, L, T->l, k);
        R = T;
        R->calc();
    }
    else
    {
        split(T->r, T->r, R, k - kl - 1);
        L = T;
        L->calc();
    }
}

vector<int> p;
void dfs(treap* v)
{
    if (v == nullptr) return;
    dfs(v->l);
    //  cout << v->x << " ";
    p.pb(v->x);
    dfs(v->r);
}
void dfs1(treap* v)
{
    if (v == nullptr) return;
    dfs1(v->l);
 //   cout << v->x << " ";
  printf("%d ", v->x);
    //p.pb(v->x);
    dfs1(v->r);
}
int jj;
void make(treap* &v)
{
    if (v == nullptr) return;
    make(v->l);

    v->x = p[jj];
    jj++;

    make(v->r);
}
int  f[1001000];

int  g[1001000];

int readInt() {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();

    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch - '0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result * 10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int main()
{
    srand(time(NULL));

  //    freopen("input.txt", "r", stdin);
 //     freopen("output.txt", "w", stdout);

    treap* root;
    root = nullptr;
    int n, m;
    cin >> n >> m;
    for (int i(1); i <= n; i++)
    {
        treap* a = new treap(-1, rand());
        merge(root, root, a);
    }
    for (int i(0); i < m; i++)
    {
        int a, b;
   //     scanf("%d%d", &a, &b);
        a = readInt();
        b = readInt();
        g[i] = b;
        treap *x, *y, *z, *q;
        split(root, x, y, b);
        split(x, q, z, b - 1);
        if (f[a] != 0 && z->x != a)
        {
            cout << -1; return 0;
        }
        if (z->x != a && z->x != -1)
        {
            cout << -1; return 0;
        }
        z->x = a;
        merge(root, z, q);
        merge(root, root, y);

    }
    dfs(root);
    int k = 0, ind = -1;
    for (int i(0); i < p.size(); i++)
        if (p[i] == -1) k++;
        else
        {
            if (f[p[i]] == -1)
            {
                cout << -1; return 0;
            }
            f[p[i]] = -1;
        }
    int j = 1;
    for (int i(0); i < p.size(); i++)
    {
        if (p[i] != -1) continue;
        while (j <= n && f[j] == -1) j++;
        if (j > n)
        {
            cout << -1; return 0;
        }
        f[j] = -1;
        p[i] = j;
    }
    if (ind != -1) p[ind] = j;

    jj = 0;
    make(root);

     if (n == m && n == 1000000) return 0;

    for (int i(m - 1); i >= 0; i--)
    {
        int k = g[i] - 1;
        if (k == 0) continue;
        treap *x, *y, *z, *q;
        split(root, x, y, 1);
        split(y, z, q, k);
        merge(root, z, x);
        merge(root, root, q);
    }
    dfs1(root);
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e6;
bool numbers[MAXN + 7];
int last = 1;

namespace Treap {
  struct Node {
    int val;
    int order;
    int cnt;
    Node *left, *right;
  };

  typedef Node* NodeP;

  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  NodeP new_node(int val) {
    NodeP temp = new Node;
    temp->val = val;
    temp->order = uniform_int_distribution<int>(0, 1e9)(rng);
    temp->cnt = 1;
    temp->left = NULL;
    temp->right = NULL;
    return temp;
  }

  void delete_node(NodeP temp) {
    delete temp;
  }

  int cnt(NodeP t) {
    if (!t) {
      return 0;
    }
    return t->cnt;
  }

  void update_cnt(NodeP t) {
    if (t) {
      t->cnt = cnt(t->left) + 1 + cnt(t->right);
    }
  }

  void split(NodeP t, NodeP &l, NodeP &r, int x, int add) {
    if (t == NULL) {
      l = NULL;
      r = NULL;
    }
    else {
      int key = add + 1 + cnt(t->left);
      if (key >= x) {
        split(t->left, l, t->left, x, add);
        r = t;
      }
      else {
        split(t->right, t->right, r, x, add + 1 + cnt(t->left));
        l = t;
      }
    }
    update_cnt(l);
    update_cnt(r);
  }

  void merge(NodeP &t, NodeP l, NodeP r) {
    if (l == NULL) {
      t = r;
    }
    else if (r == NULL) {
      t = l;
    }
    else {
      if (l->order > r->order) {
        merge(l->right, l->right, r);
        t = l;
      }
      else {
        merge(r->left, l, r->left);
        t = r;
      }
    }
    update_cnt(t);
  }

  void insert(NodeP &t, NodeP x, int xkey, int add) {
    if (t == NULL) {
      t = x;
    }
    else {
      int key = add + 1 + cnt(t->left);
      if (key >= xkey) {
        insert(t->left, x, xkey, add);
      }
      else {
        insert(t->right, x, xkey, add + 1 + cnt(t->left));
      }
    }
    update_cnt(t);
  }

  bool erase(NodeP &t, int xkey, int y, int add) {
    if (t != NULL) {
      int key = add + 1 + cnt(t->left);
      if (key == xkey) {
        NodeP temp = t;
        merge(t, t->left, t->right);
        if (numbers[y] == true and temp->val != y) {
          return false;
        }
        else if (numbers[y] == false and temp->val != -1) {
          return false;
        }
        delete_node(temp);
      }
      else if (key > xkey) {
        return erase(t->left, xkey, y, add);
      }
      else {
        return erase(t->right, xkey, y, add + 1 + cnt(t->left));
      }
    }
    update_cnt(t);
    return true;
  }

  void print_node(NodeP t) {
    if (t) {
      print_node(t->left);
      cerr << "v: " << t->val << "\n";
      print_node(t->right);
    }
  }
};

Treap::NodeP root;

void add(int x, int y) {
  Treap::NodeP temp = Treap::new_node(y);
  Treap::insert(root, temp, x, 0);
}

bool move(int x, int y) {
  if (!Treap::erase(root, 1, y, 0)) {
    return false;
  }

  Treap::NodeP temp = Treap::new_node(y);
  Treap::insert(root, temp, x, 0);
  numbers[y] = true;
  return true;
}

void print(Treap::NodeP t) {
  if (!t) {
    return;
  }
  if (t->left) {
    print(t->left);
  }
  if (t->val != -1) {
    printf("%d ", t->val);
  }
  else {
    while (numbers[last] == true) {
      last++;
    }
    printf("%d ", last);
    last++;
  }
  if (t->right) {
    print(t->right);
  }
}

int x[MAXN + 7];
int y[MAXN + 7];

int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    add(i, -1);
  }

  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x[i], &y[i]);
  }
  for (int i = m; i >= 1; i--) {
    if (!move(y[i], x[i])) {
      printf("-1\n");
      return 0;
    }
  }

  print(root);
  printf("\n");

  return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>

using namespace std;

const int maxn=1000000;

int s[maxn*2+1],ch[maxn*2+1][2],o[maxn+1],c[maxn+1],n,m,a,b,tt=0;

void reloc()
{
    freopen("/Users/admin/Desktop/cards.in","r",stdin);
    freopen("/Users/admin/Desktop/cards.out","w",stdout);
    return;
}

void buildtree(int l,int r)
{
    if(l>r)return;
    tt++;
    int now=tt;
    s[tt]=0;
    if(l==r)
    {
        ch[tt][0]=ch[tt][1]=0;
        return;
    }
    int mid=(l+r)/2;
    ch[tt][0]=tt+1;
    buildtree(l,mid);
    ch[now][1]=tt+1;
    buildtree(mid+1,r);
    return;
}

int findp(int root, int l,int r,int po)
{

    if(l==r)return l;
    int mid=(l+r)>>1;
    //printf("root=%d evaluation=%d goal=%d\n",root,mid+s[ch[root][1]],po);
    //if(mid+s[ch[root][1]]+((c[mid])&&1)==po)return mid;
    if(mid+s[ch[root][1]]+1>po)return findp(ch[root][0],l,mid,po-s[ch[root][1]]);

    else return findp(ch[root][1],mid+1,r,po);
}

void update(int root,int l,int r,int p)
{

    if(root==0)return;
    if(p<l||r<p)return;
    //printf("root=%d\n",root);
    s[root]++;
    if(l==r)return;
    int mid=(l+r)>>1;
    update(ch[root][0],l,mid,p);
    update(ch[root][1],mid+1,r,p);
    return;
}

void print()
{
    queue<int> q;
    for(int i=1;i<=n;i++)if(o[i]==0)q.push(i);
    for(int i=1;i<n;i++)
    {
        if(c[i]==0)
        {
            printf("%d ",q.front());
            q.pop();
        }
        else
        {
            printf("%d ",c[i]);

        }
    }
    int i=n;
    if(c[i]==0)
    {
        printf("%d\n",q.front());
        q.pop();
    }
    else
    {
        printf("%d\n",c[i]);

    }
    return;

}

void read()
{

    memset(c,0,sizeof(c));
    memset(s,0,sizeof(s));
    memset(o,0,sizeof(o));
    memset(ch,0,sizeof(ch));
    scanf("%d%d",&n,&m);
    buildtree(1,n);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        if(o[a]==0)
        {
            int p=findp(1,1,n,b);
            //cout<<p<<endl;
            update(1,1,n,p);
            o[a]=i;
            if(c[p])
            {
                cout<<-1<<endl;
                return;
            }
            c[p]=a;

        }
        else
        {
            int l=i-o[a];
            if(b!=l)
            {
                cout<<-1<<endl;
                return;
            }
        }
    }
    print();
    return;
}

int main()
{
    //reloc();
    read();
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:167777216")
#include <cmath>
#include <math.h>
#include <complex>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>

#include <unordered_map>
#include <stack>
#include <time.h>
#include <fstream>
#include <queue>
using namespace std;

#define pb push_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second

#define all(x) x.begin(), x.end()
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define M_PI       3.14159265358979323846
#define PI       3.14159265358979323846
typedef long long ll;
typedef  unsigned long long ull;
typedef  long double ld;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef int huint;
const ll Mll = 1000000000000000000;
const ll Mint = 1000000000;

ll mod = 1000000007;

struct treap
{
    treap *l{ nullptr }, *r{ nullptr };
    int k, y, x;
    treap()
    {
        x = 0, y = 0, k = 0;
        r = l = nullptr;
    }
    treap(ll x1, ll y1)
    {
        x = x1, y = y1;
    }
    void calc()
    {
        if (this == nullptr) return;
        k = 1;
        if (r != nullptr) k += r->k;
        if (l != nullptr) k += l->k;
    }
};
void merge(treap* &T, treap* L, treap* R)
{
    if (L == nullptr)
    {
        T = R; T->calc();
        return;
    }
    if (R == nullptr)
    {
        T = L; T->calc();
        return;
    }
    if (L->y > R->y)
    {
        merge(L->r, L->r, R);
        T = L;
    }
    else
    {
        merge(R->l, L, R->l);
        T = R;
    }
    T->calc();
}
void split(treap* T, treap* &L, treap* &R, int k)
{
    if (T == nullptr)
    {
        L = R = nullptr;
        return;
    }
    int kl = 0;
    if (T->l != nullptr) kl = T->l->k;
    if (kl >= k)
    {
        split(T->l, L, T->l, k);
        R = T;
        R->calc();
    }
    else
    {
        split(T->r, T->r, R, k - kl - 1);
        L = T;
        L->calc();
    }
}

vector<int> p;
void dfs(treap* v)
{
    if (v == nullptr) return;
    dfs(v->l);
    //  cout << v->x << " ";
    p.pb(v->x);
    dfs(v->r);
}
void dfs1(treap* v)
{
    if (v == nullptr) return;
    dfs1(v->l);
 //   cout << v->x << " ";
 printf("%d ", v->x);
    //p.pb(v->x);
    dfs1(v->r);
}
int f[1001000];

int g[1001000];

int readInt() {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();

    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch - '0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result * 10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int main()
{
    srand(time(NULL));

 //    freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);

    treap* root;
    root = nullptr;
    int n, m;
    cin >> n >> m;
    for (int i(1); i <= n; i++)
    {
        treap* a = new treap(-1, rand());
        merge(root, root, a);
    }
    for (int i(0); i < m; i++)
    {
        int a, b;
   //     scanf("%d%d", &a, &b);
        a = readInt();
        b = readInt();
        g[i] = b;
        treap *x, *y, *z, *q;
        split(root, x, y, b);
        split(x, q, z, b - 1);
        if (f[a] != 0 && z->x != a)
        {
            cout << -1; return 0;
        }
        if (z->x != a && z->x != -1)
        {
            cout << -1; return 0;
        }
        z->x = a;
        merge(root, z, q);
        merge(root, root, y);

    }
    if (n == m && n == 1000000) return 0;
    dfs(root);
    int k = 0, ind = -1;
    for (int i(0); i < p.size(); i++)
        if (p[i] == -1) k++;
        else
        {
            if (f[p[i]] == -1)
            {
                cout << -1; return 0;
            }
            f[p[i]] = -1;
        }
    int j = 1;
    for (int i(0); i < p.size(); i++)
    {
        if (p[i] != -1) continue;
        while (j <= n && f[j] == -1) j++;
        if (j > n)
        {
            cout << -1; return 0;
        }
        f[j] = -1;
        p[i] = j;
    }
    if (ind != -1) p[ind] = j;

    treap* nroot = nullptr;
    for (int i(0); i < p.size(); i++)
    {
        treap* a = new treap(p[i], rand());
        merge(nroot, nroot, a);
    }
    // if (n == m && n == 1000000) return 0;

    for (int i(m - 1); i >= 0; i--)
    {
        int k = g[i] - 1;
        if (k == 0) continue;
        treap *x, *y, *z, *q;
        split(nroot, x, y, 1);
        split(y, z, q, k);
        merge(nroot, z, x);
        merge(nroot, nroot, q);
    }
    dfs1(nroot);
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
using namespace std;

const int N = 1000100;

#define LL(x) ch[x][0]
#define RR(x) ch[x][1]

int ch[N][2], sz[N], rank[N], val[N], ls[N], rs[N], lazy[N], tot;

void init(){
	tot = 0;
	LL(tot) = RR(tot) = 0;
	sz[tot] = 0; lazy[tot] = 0;
}

int new_node(int k=0, int b=0){
	tot++;
	LL(tot) = RR(tot) = 0;
	sz[tot] = 1; rank[tot] = ls[tot] = rs[tot] = k; val[tot] = b; lazy[tot] = 0;
	return tot;
}

void push_down(int x){
	if(!x)return;
	rank[LL(x)] += lazy[x]; lazy[LL(x)] += lazy[x]; ls[LL(x)] += lazy[x]; rs[LL(x)] += lazy[x];
	rank[RR(x)] += lazy[x]; lazy[RR(x)] += lazy[x]; ls[RR(x)] += lazy[x]; rs[RR(x)] += lazy[x];
	lazy[x] = 0;
}

void push_up(int x){
	if(!x)return;
	sz[x] = sz[LL(x)] + 1 + sz[RR(x)];
	ls[x] = rs[x] = rank[x];
	if(LL(x)){
		ls[x] = min(ls[x], ls[LL(x)]);
	}
	if(RR(x)){
		rs[x] = max(rs[x], rs[RR(x)]);
	}
}

void Rotate(int &x, int k){
	if(!x)return;
	int tmp = ch[x][k];
	push_down(x); push_down(tmp);
	ch[x][k] = ch[tmp][!k];
	push_up(x);
	ch[tmp][!k] = x;
	x = tmp;
}

void Maintain(int &x, int k){
	if(!x)return;
	if(sz[ch[ch[x][k]][k]] > sz[ch[x][k^1]]){
		Rotate(x, k);
	}
	else if(sz[ch[ch[x][k]][k^1]] > sz[ch[x][k^1]]){
		Rotate(ch[x][k], k^1); Rotate(x, k);
	}
	else
		return;
	Maintain(LL(x), 0);
	Maintain(RR(x), 1);
	Maintain(x, 0);
	Maintain(x, 1);
	push_up(x);
}

void Insert(int &rt, int v, int b){
	if(!rt){
		rt = new_node(v, b);
		return;
	}
	push_down(rt);
	if(v < rank[rt])
		Insert(LL(rt), v, b);
	else
		Insert(RR(rt), v, b);
	push_up(rt);
	if(v < rank[rt])
		Maintain(rt, 0);
	else
		Maintain(rt, 1);
}

pair<int,int> Delete(int &rt, int k){
	if(!rt) return make_pair(-1, -1);
	push_down(rt);
	if(sz[LL(rt)]+1 == k){
		pair<int,int> ret = make_pair(rank[rt], val[rt]);
		if(LL(rt)==0 || RR(rt)==0)
			rt = LL(rt) + RR(rt);
		else{
			pair<int,int> tmp = Delete(LL(rt), k-1);
			rank[rt] = tmp.first; val[rt] = tmp.second;
		}
		push_up(rt);
		return ret;
	}
	pair<int,int> ret;
	if(k <= sz[LL(rt)])
		ret = Delete(LL(rt), k);
	else
		ret = Delete(RR(rt), k-sz[LL(rt)]-1);
	push_down(rt);
	return ret;
}

pair<int,int> del(int &rt, int v){
	if(!rt)return make_pair(-1, -1);
	push_down(rt);
	if(v == rank[rt]){
		pair<int,int> ret = make_pair(rank[rt], val[rt]);
		if(LL(rt)==0 || RR(rt)==0)
			rt = LL(rt) + RR(rt);
		else{
			pair<int,int> tmp = Delete(LL(rt), sz[LL(rt)]);
			rank[rt] = tmp.first; val[rt] = tmp.second;
		}
		push_up(rt);
		return ret;
	}
	pair<int,int> ret;
	if(v < rank[LL(rt)])
		ret = del(LL(rt), v);
	else
		ret = del(RR(rt), v);
	push_down(rt);
	return ret;
}

void update(int rt, int l, int r, int v){
	if(!rt)return;
	if(l>r || l>rs[rt] || r<ls[rt])return;
	if(l<=ls[rt] && rs[rt]<=r){
		rank[rt] += v; lazy[rt] += v; ls[rt] += v; rs[rt] += v;
		return;
	}
	push_down(rt);
	if(r < rank[rt])
		update(LL(rt), l, r, v);
	else if(l > rank[rt])
		update(RR(rt), l, r, v);
	else{
		update(LL(rt), l, rank[rt]-1, v);
		rank[rt] += v;
		update(RR(rt), rank[rt]+1, r, v);
	}
	push_up(rt);
}

int get_min(int rt){
	while(LL(rt)){
		push_down(rt);
		rt = LL(rt);
	}
	return rank[rt];
}

pair<int,int> fir_val(int rt){
	while(LL(rt)){
		push_down(rt);
		rt = LL(rt);
	}
	return make_pair(rank[rt], val[rt]);
}

int n, m, x[N], y[N], ans[N];
bool vis[N];

void dfs(int rt){
	if(!rt)return;
	dfs(LL(rt));
	ans[rank[rt]] = val[rt];
	dfs(RR(rt));
}

bool solve(){
	init();
    int rt = 0;
    for(int i=m-1; i>=0; i--){
    	if(!vis[x[i]]){
    		vis[x[i]] = 1;
    		int l = get_min(rt);
    		if(rt && l==1)
    			return false;
    		update(rt, 2, y[i], -1);
    		Insert(rt, y[i], x[i]);
    	}
    	else{
    		pair<int,int> l = fir_val(rt);
    		if(rt && (l.second!=x[i] || l.first!=1))
    			return false;
    		del(rt, 1);
    		update(rt, 2, y[i], -1);
    		Insert(rt, y[i], x[i]);
    	}
    }
    dfs(rt);
    int p = 1;
    for(int i=1; i<=n; i++){
    	if(ans[i] == 0){
    		while(p<=n && vis[p])
    			p++;
    		// printf("%d %d\n", i, p);
    		ans[i] = p;
    		p++;
    	}
    	 printf("%d ", ans[i]);
    }
    return true;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i=0; i<m; i++)
    	scanf("%d%d", &x[i], &y[i]);
    if(!solve())
    	puts("-1");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)

typedef long long ll;
typedef pair < int, int > ii;

const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;

const int N = 1 << 21;

int n, m;
int a[N], b[N], arr[N], ans[N], fen[N];

void up(int x, int k) {
	for(; x < N; x += x & -x)
		fen[x] += k;
}

int get(int x) {
	int num = 0, sum = 0;
	for(int i = 20; i >= 0; i--) {
		if(fen[num | (1 << i)] + sum < x) {
			num |= 1 << i;
			sum += fen[num];
		}
	}
	return num + 1;
}

void assign(int i, int x) {
	if(ans[i] and ans[i] != x) {
		puts("-1");
		exit(0);
	}
	ans[i] = x;
}

int main() {

	scanf("%d %d", &n, &m);

	for(int i = 1; i <= n; i++) {
		up(i + n, 1);
		arr[i + n] = i;
	}

	int ptr = n;

	for(int i = 1; i <= m; i++) {
		scanf("%d %d", a + i, b + i);
		int x = get(b[i]);
		int k = arr[x];
		assign(k, a[i]);
		up(x, -1);
		up(ptr, +1);
		arr[x] = 0;
		arr[ptr] = k;
		ptr--;
	}

	for(int i = 1; i <= n; i++) {
		int x = get(i);
		//printf("arr[%d] = %d\n", x, arr[x]);
	}

	set < int > s;

	for(int i = 1; i <= n; i++)
		s.insert(i);

	vector < int > vs;

	for(int i = 1; i <= n; i++)
		if(ans[i])
			vs.push_back(ans[i]);

	sort(vs.begin(), vs.end());

	if(unique(vs.begin(), vs.end()) != vs.end()) {
		puts("-1");
		return 0;
	}

	int x = 1;
	ptr = 0;

	for(int i = 1; i <= n; i++) {
		if(ans[i])
			continue;
		while(ptr < vs.size() and vs[ptr] == x) {
			x++;
			ptr++;
		}
		if(ptr == vs.size() or x > n) {
			puts("-1");
			return 0;
		}
		ans[i] = x++;
	}

	for(int i = 1; i <= n; i++) {
		printf("%d ", ans[i]);
	}

	puts("");

	return 0;

}

#include <bits/stdc++.h>

using namespace std;

const int N = 1000005;

int order[N], vis[N];

struct nd{
    int p, cnt, idx, label;
    nd *l, *r;
    nd(){}
    nd(int idx) : idx(idx), p((rand() << 15) + rand()), cnt(1), label(- 1), l(NULL), r(NULL){}
};

nd *root = NULL, n_nd[N]; int nd_cnt = 0;

int cnt(nd* t){return t ? t->cnt : 0;}
void upt(nd* t){if(!t) return; t->cnt = cnt(t->l) + 1 + cnt(t->r);}

nd* new_nd(int idx){
    nd* t = &n_nd[nd_cnt++];
    t->idx = idx;
    t->p = (rand() << 15) + rand();
    t->cnt = 1;
    t->label = - 1;
    t->l = t->r = NULL;
    return t;
}

void split(nd* t, nd* &l, nd* &r, int p){
    if(!t) l = r = NULL;
    else if(p <= cnt(t->l)) split(t->l, l, t->l, p), r = t;
    else split(t->r, t->r, r, p - cnt(t->l) - 1), l = t;
    upt(t);
}

void merge(nd* &t, nd* l, nd* r){
    if(!l || !r) t = l ? l : r;
    else if(l->p > r->p) merge(l->r, l->r, r), t = l;
    else merge(r->l, l, r->l), t = r;
    upt(t);
}

void ins(nd* &t, nd* nn, int p){
    if(!t) t = nn;
    else if(nn->p > t->p) split(t, nn->l, nn->r, p), t = nn;
    else if(p <= cnt(t->l)) ins(t->l, nn, p);
    else ins(t->r, nn, p - cnt(t->l) - 1);
    upt(t);
}

void del(nd* &t, int p){
    if(cnt(t->l) == p) merge(t, t->l, t->r);
    else if(p < cnt(t->l)) del(t->l, p);
    else del(t->r, p - cnt(t->l) - 1);
    upt(t);
}

nd* get_nd(nd* t, int p){
    if(cnt(t->l) == p) return t;
    else if(p < cnt(t->l)) return get_nd(t->l, p);
    else return get_nd(t->r, p - cnt(t->l) - 1);
}

void prt(nd* t){
    if(!t) return;
    prt(t->l);
    order[t->idx] = t->label;;
    prt(t->r);
}

void heapify(nd* t){
    if(!t) return;
    nd* max = t;
    if(t->l && t->l->p > t->p) max = t->l;
    if(t->r && t->r->p > t->p) max = t->r;
    if(max != t){
        swap(max->p, t->p);
        heapify(max);
    }
}

nd* build(int lo, int hi){
    if(lo > hi) return NULL;
    int mid = (lo + hi) >> 1;
    nd* t = new_nd(mid);
    t->l = build(lo, mid - 1);
    t->r = build(mid + 1, hi);
    heapify(t);
    return t;
}

void init(nd* t, int add = 0){
    if(!t) return;
    init(t->l);
    init(t->r, add + cnt(t->l) + 1);
    upt(t);
    t->idx = add + cnt(t->l);

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(NULL));
    int n, m, x, y; cin >> n >> m;
    //for(int i = 0; i < n; i++) ins(root, new_nd(i), i);
    root = build(0, n - 1);
    init(root);
    while(m--){
        cin >> x >> y;
        y--; x--;
        nd* t = get_nd(root, y);
        del(root, y);
        if((t->label == - 1 && vis[x]) || (t->label != - 1 && t->label != x)){
            cout << - 1 << "\n";
            return 0;
        }
        vis[x] = true;
        t->label = x;
        t->l = t->r = NULL;
        t->cnt = 1;
        ins(root, t, 0);
    }
    prt(root);
    int idx = 0;
    for(int i = 0; i < n; i++){
        if(order[i] != - 1) cout << order[i] + 1 << " ";
        else{
            while(vis[idx]) idx++;
            cout << idx + 1 << " ";
            idx++;
        }
    }
    cout << "\n";
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;

#define TRACE(x...) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define PRINT(x...) TRACE(printf(x))

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define FU(i, a, b) for(decltype(a) i = (a); i < (b); ++i)
#define fu(i, n) FU(i, 0, n)

#define mset(c, v) memset(c, v, sizeof(c))
#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define SZ(c) int((c).size())

const int INF = 0x3F3F3F3F; const int NEGINF = 0xC0C0C0C0;
const double EPS = 1e-8;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef long long ll;

class BIT {
	private:
		vector<int> tree;
		int N;
	public:
		BIT(int _N){
			N = _N+1;
			tree.resize(N,0);
		}

		void update(int ind, int value){
			ind++;
			while(ind<N)
			{
				tree[ind] += value;
				ind += (ind & -ind);
			}
		}

		int get(int ind){
			int sum=0;
			while(ind > 0)
			{
				sum += tree[ind];
				ind -= (ind & -ind);
			}
			return sum;
		}

		int get(int ind1, int ind2)	{
			if (ind1>=ind2) return 0;
			return get(ind2) - get(ind1);
		}
};

int cmp(double x, double y = 0, double tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
char ans[10000000];
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	BIT bit(n+1), bit2(n+1);
	vi pos(n, -1), last(n, -1), used(n, -1);
	bool valid = true;
	int k = 0;
	fu(i, m) {
		int x, y;
		scanf("%d %d", &x, &y); x--; y--;
		if (pos[x] == -1) {
			if (y < k) {
				valid = false;
				break;
			}
			pos[x] = -1;
			int mi = 0;
			int ma = n;
			while (ma > mi) {
				int me = (ma + mi)/2;
				int z = me + k - bit.get(me);
				if (used[me] == -1 && z == y) {
					used[me] = x;
					pos[x] = me;
					bit.update(me, +1);
					break;
				} else if (z <= y) mi = me + 1;
				else ma = me;
			}
			if (pos[x] == -1) {
				valid = false;
				break;
			}
			k++;
		} else {
			if (y >= k) {
				valid = false;
				break;
			}
			int poss = k - last[x] - 1 + bit2.get(last[x]);
			if (y != poss) {
				valid = false;
				break;
			}
			bit2.update(last[x], +1);
		}
		last[x] = i;
	}
	if (!valid) printf("-1\n");
	else {
		int cur = 0;
		int posi = 0;
		fu(i, n) {
			if (i) ans[posi++] = ' ';
			if (used[i] != -1) posi += sprintf(ans + posi, "%d", used[i]+1);
			else {
				while (pos[cur] != -1) cur++;
				posi += sprintf(ans + posi, "%d", cur+1);
				cur++;
			}
		}
		ans[posi] = '\0';
		printf("%s\n", ans);
	}
	return 0;
}

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
#include <bits/stdc++.h>
#define DEBUG 1
using namespace std;

namespace output{
    void __(short x){cout<<x;}
    void __(unsigned x){cout<<x;}
    void __(int x){cout<<x;}
    void __(long long x){cout<<x;}
    void __(unsigned long long x){cout<<x;}
    void __(double x){cout<<x;}
    void __(long double x){cout<<x;}
    void __(char x){cout<<x;}
    void __(const char*x){cout<<x;}
    void __(const string&x){cout<<x;}
    void __(bool x){cout<<(x?"true":"false");}
    template<class S,class T>
    void __(const pair<S,T>&x){__(DEBUG?"(":""),__(x.first),__(DEBUG?", ":" "),__(x.second),__(DEBUG?")":"");}
    template<class T>
    void __(const vector<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    template<class T>
    void __(const set<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    template<class T>
    void __(const multiset<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    template<class S,class T>
    void __(const map<S,T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    void pr(){cout<<"\n";}
    template<class S,class... T>
    void pr(const S&a,const T&...b){__(a);if(sizeof...(b))__(' ');pr(b...);}
}

using namespace output;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,char> pic;
typedef pair<double,double> pdd;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;

#define pb push_back
#define fox(i,x,y) for(int i=(x);i<=(y);i++)
#define foxr(i,x,y) for(int i=(y);i>=(x);i--)
#define F first
#define S second

const int MN = 1e6+6;
int n, m, i, j, x, y, pos[MN], lst[MN], use[MN], nxt, fl;
pii arr[MN]; queue<int> fr;

struct nd{
    int k, sz, p; nd *l, *r;
    nd(int id):k(id),sz(1),p(rand()),l(0),r(0){}
}*rt,*l,*r,*t;
inline int sz(nd *n){return n?n->sz:0;}
inline void upd(nd *&n){if(n)n->sz=sz(n->l)+sz(n->r)+1;}
void split(nd *n,nd *&l,nd *&r,int k){
    if(!n) l=r=NULL;
    else if(sz(n->l)+1<=k) split(n->r,n->r,r,k-sz(n->l)-1), l=n;
    else split(n->l,l,n->l,k), r=n;
    upd(n);
}
void mrg(nd *&n,nd *l,nd *r){
    if(!l||!r) n=l?l:r;
    else if(l->p>r->p) mrg(l->r,l->r,r), n=l;
    else mrg(r->l,l,r->l), n=r;
    upd(n);
}

int main(){
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++){
        scanf("%d%d",&arr[i].F,&arr[i].S);
        if(lst[arr[i].F]){
            if(i-lst[arr[i].F]!=arr[i].S) fl=1;
        }
        lst[arr[i].F]=i;
    }
    if(fl) printf("-1\n");
    else{
        rt = NULL;
        for(i=1;i<=n;i++)
            mrg(rt, rt, new nd(++nxt));
        for(i=1;i<=m;i++){
            if(!pos[arr[i].F]){
                split(rt, l, r, arr[i].S);
                split(l, l, t, arr[i].S-1);
                int id = t->k;
                if(use[id]){
                    fl = 1;
                    break;
                }
                use[id] = arr[i].F;
                pos[arr[i].F] = id;
                mrg(l, l, t);
                mrg(rt, l, r);
            }
            split(rt, l, r, arr[i].S);
            split(l, l, t, arr[i].S-1);
            mrg(l, t, l);
            mrg(rt, l, r);
        }
        if(fl) printf("-1\n");
        else{
            for(i=1;i<=n;i++){
                if(!pos[i]) fr.push(i);
            }
            for(i=1;i<=n;i++){
                if(use[i]) printf("%d ",use[i]);
                else{
                    x = fr.front(); fr.pop();
                    printf("%d ",x);
                }
            }
            printf("\n");
        }
    }
    return 0;
}

//============================================================================
// Name        : cf.cpp
// Author      : HX
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>

using namespace std;
#define  N   3111113
#define  M   22222
#define  eps 1e-8
#define  pi  acos(-1.0)
#define  inf 0XFFFFFFFll
#define  mod 1000000007ll
#define  LL  long long
// 同线段树一样，当前节点有lazy标记且信息正确
// 插入节点 root->ch[1]->setc(newNodw(v), 0);
// 初始化 root = build(a, 0, n+2); root->p = null; cur = pool;
// 哨兵节点a[0], a[n+1];
namespace Splay {
	struct Node {
		int size, val;
		Node *p, *ch[2];
		Node() : size(0), val(0) {
			p = ch[0] = ch[1] = NULL;
		}
		void setc(Node *c, int d) {
			ch[d] = c;
			c->p = this;
		}
		bool d() {
			return this == this->p->ch[1];
		}

		void relax();
		void upd() {
			size = 1 + ch[0]->size + ch[1]->size;
		}
	}Tnull, *null = &Tnull;
	Node pool[N], *cur = pool, *root;

	void Node::relax() {
	}

	Node* newNode(int _val = 0) {
		cur->size = 1;
		cur->p = cur->ch[0] = cur->ch[1] = null;
		cur->val = _val;
		return cur++;
	}

	Node* buildtree(int a[], int l, int r) { //[l, r)
		if (l >= r)
			return null;
		int m = (l + r) >> 1;
		Node *ret = newNode(a[m]);
		ret->setc(buildtree(a, l, m), 0);
		ret->setc(buildtree(a, m+1, r), 1);
		ret->upd();
		return ret;
	}

	void rot(Node *t) {
		Node *p = t->p;
		p->relax();
		t->relax();
		int d = t->d();
		p->p->setc(t, p->d());
		p->setc(t->ch[!d], d);
		t->setc(p, !d);
		p->upd();
		if (root == p)
			root = t;
	}

	void splay(Node *t, Node *f = null) {
		while (t->p != f) {
			if (t->p->p == f)
				rot(t);
			else if (t->d() == t->p->d())
				rot(t->p), rot(t);
			else
				rot(t), rot(t);
		}
		t->upd();
	}

	Node* select(int k) {
		for (Node*t = root;;) {
			t->relax();
			int c = t->ch[0]->size + 1;
			if (c == k)
				return t;
			if (c > k)
				t = t->ch[0];
			else
				k -= c, t = t->ch[1];
		}
	}

	void getInterval(int l, int r) { //[l, r)
		Node *L = select(l);
		Node *R = select(r + 1);
		splay(L);
		splay(R, L);
	}
}

using namespace Splay;

int n, m;
int a[N];
int num[N];
// 同线段树一样，当前节点有lazy标记且信息正确
// 插入节点 root->ch[1]->setc(newNodw(v), 0);
// 初始化 root = build(a, 0, n+2); root->p = null; cur = pool;
// 哨兵节点a[0], a[n+1];
int x[N], y[N];
int ans[N];
int flag[N];
int cnt = 0;
void dfs(Node *now) {
	if (now->ch[0] != null)
		dfs(now->ch[0]);
	ans[cnt++] = now->val;
	flag[now->val] = true;
	if (now->ch[1] != null)
		dfs(now->ch[1]);
}

int main() {
//	freopen("cf.txt", "r", stdin);
	scanf("%d%d", &n, &m);
//	for (int i=1; i<=n+1; i++)
//		a[i] = i;
	a[0] = n + 1;
	a[n+1] = n + 2;
	cur = pool;
	root = buildtree(a, 0, n + 2);
	root->p = null;
	for (int i=0; i<m; i++) {
		scanf("%d%d", &x[m-1-i], &y[m-1-i]);
	}
	for (int i=0; i<m; i++) {
		getInterval(1, 2);
		int val = root->ch[1]->ch[0]->val;
		if (val != 0 && val != x[i]) {
			puts("-1");
			return 0;
		}
//		if (y[i] == 1) {
//			root->ch[1]->ch[0]->val = x[i];
//			continue;
//		}
		root->ch[1]->ch[0] = null;
		splay(root->ch[1]);
		getInterval(y[i], y[i]);
		a[0] = x[i];
		root->ch[1]->setc(newNode(x[i]), 0);
		splay(root->ch[1]->ch[0]);
	}
	dfs(root);
	for (int i=1; i<=n; i++) {
		num[ans[i]]++;
		if (num[i] > 1) {
			puts("-1");
			return 0;
		}
	}
	for (int i=1, j=1; i<=n; i++) {
		if (ans[i] == 0) {
			while (flag[j] == true)
				j++;
			ans[i] = j;
			j++;
		}
	}
	for (int i=1; i<=n; i++)
		printf("%d ", ans[i]);
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

const int MAXN = 1000000;
int n, t[4*MAXN];
void build (int a[], int v, int tl, int tr) {
    if (tl == tr)
        t[v] = a[tl];
    else {
        int tm = (tl + tr) / 2;
        build (a, v*2, tl, tm);
        build (a, v*2+1, tm+1, tr);
    }
}

void update (int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        t[v] += add;
    else {
        int tm = (tl + tr) / 2;
        update (v*2, tl, tm, l, min(r,tm), add);
        update (v*2+1, tm+1, tr, max(l,tm+1), r, add);
    }
}

int get (int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get (v*2, tl, tm, pos);
    else
        return t[v] + get (v*2+1, tm+1, tr, pos);
}

struct item {
    int prior, cnt, add;
    int pos;
    ll key;
    item * l, * r;
    item() : l(nullptr), r(nullptr), cnt(0) { }
    item (int key, int prior) : key(key), prior(prior), l(nullptr), r(nullptr), cnt(0){ }
};
typedef item * pitem;

int cnt (pitem t) {
    return t ? t->cnt : 0;
}

void push (pitem it) {
    if (it && it->add) {
        if (it->l)  it->l->add = it->add;
        if (it->r)  it->r->add = it->add;
        it->add = 0;
    }
}

void upd_cnt (pitem t) {
    if (t)
        t->cnt = 1 + cnt(t->l) + cnt (t->r);
}

void upd_all (pitem t) {
    upd_cnt(t);
}

void merge (pitem & t, pitem l, pitem r) {
    if (!l || !r)
        t = l ? l : r;
    else if (l->prior > r->prior || (l->prior == r->prior && rand()%2))
        merge (l->r, l->r, r),  t = l;
    else
        merge (r->l, l, r->l),  t = r;
    upd_all (t);
}

void split (pitem t, pitem & l, pitem & r, ll key, int add = 0) {
    if (!t)
        return void( l = r = 0 );
    // int cur_key = add + cnt(t->l);
    if (key < t->key || (key==t->key && rand()%2))
        split (t->l, l, t->l, key, add),  r = t;
    else
        split (t->r, t->r, r, key, add),  l = t;
    upd_all (t);
}

void insert (pitem & t, pitem it) {
    if (!t)
        t = it;
    else if (it->prior > t->prior || (it->prior == t->prior && rand()%2))
        split (t, it->l, it->r, it->key),  t = it;
    else {
        if (it->key == t->key && rand() % 2) insert(t->l, it);
        else insert (it->key < t->key ? t->l : t->r, it);
    }
    upd_all (t);
}

void erase (pitem & t, ll key) {
    if (t->key == key)
        merge (t, t->l, t->r);
    else
        erase (key < t->key ? t->l : t->r, key);
    upd_all (t);
}

//pitem unite (pitem l, pitem r) {
//    if (!l || !r)  return l ? l : r;
//    if (l->prior < r->prior)  swap (l, r);
//    pitem lt, rt;
//    split (r, lt, rt, l->key);
//    l->l = unite (l->l, lt);
//    l->r = unite (l->r, rt);
//    return l;
//}

//void add (pitem t, int l, int r) {
//    pitem t1, t2, t3;
//    split (t, t1, t2, l);
//    split (t2, t2, t3, r-l+1);
//    t2->rev ^= true;
//    merge (t, t1, t2);
//    merge (t, t, t3);
//}

pitem search (pitem t, ll key) {
    if (t->key > key) {
        t->r->pos = t->pos + 1;
        if(t->l != nullptr) t->r->pos += t->l->cnt;
        return search(t->r, key);
    }
    else if (t->key < key) {
        t->l->pos = t->pos;
        return search(t->l, key);
    }
    else return t;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    int n,m;

    scanf("%d %d", &n, &m);
    vi ans(n,-1);
    vi a(n);
    forn(i,0,n) a[i]=i;
    build(a.data(),1,0,n-1);
    int pr = 0;
    vi where(n,-1);
    int cur = 0;
    std::vector<int> prior;
    for (int i=0; i<m; ++i) prior.push_back(i);
    std::random_shuffle (all(prior));
    vector<item> items(n);
    vi p(n,0);
    pitem root(nullptr);
    forn(i,0,m) {
        int x,y;
        scanf("%d %d", &x, &y);
        x--; y--;
        if(y>=pr) {

            // ne trogali
            if(where[x] >= 0) {
                cout<<-1;
                return 0;
            }
            int st = get(1,0,n-1,y);
            ans[st] = x;
            where[x] = st;
            p[x] = -cur;
            items[x].prior = prior[cur];
            items[x].key=p[x];
            insert(root, &items[cur]);
            cur++;
            pr++;
            update (1, 0, n-1, pr, y, 1);
        }
        else {
            if(where[x]==-1) {
                cout<<-1;
                return 0;
            }
            root->pos = 0;
            pitem test = search(root, p[x]);
            if(test->pos != y) {
                cout<<-1;
                return 0;
            }
            erase(root, p[x]);
            p[x] = -cur;
            items[x].prior = prior[cur];
            items[x].key=p[x];
            insert(root, &items[cur]);
            cur++;
        }
    }
    vi free;
    forn(i,0,n) if(where[i]==-1) free.pb(i);
    int pc = 0;
    forn(i,0,n) {
        if(ans[i] == -1) {
            ans[i] = free[pc];
            pc++;
        }
    }
    forn(i,0,n) printf("%d ", 1+ans[i]);

}

#include <iostream>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define X first
#define Y second

using namespace std;

int x[2000000];
int y[2000000];
int n, m;
int fen[2000000];

void up(int v, int val){
	while (v <= n + 1){
		fen[v] += val;
		v = (v | (v + 1));
	}
}

int get(int v){
	int val = 0;
	while (v > 0){
		val += fen[v];
		v = (v & (v + 1)) - 1;
	}
	return val;
}

int u[2000000];

int a[2000000];
int b[2000000];
int q[2000000];

int main(){
	cin >> n >> m;
	int C = 0;
	for (int i = 1; i <= n; i++) up(i, 1);
	for (int i = 1; i <= m; i++){
		scanf("%d%d", &x[i], &y[i]);

		if (u[x[i]] == 1){
			continue;
		}
		u[x[i]] = 1;

		if (y[i]  <= C){
			cout << -1 << endl;
			return 0;
		}

		int lo = 0;
		int hi = n;
		while (lo + 1 < hi){
			int mid = (lo + hi) / 2;
			if (get(mid) >= y[i] - C) hi = mid; else lo = mid;
		}

		int p = hi;
		//cout << p << " " << y[i] - C <<  endl;

		a[p] = x[i];
		C++;

		up(p, -1);
	}

	int p = 0;
	u[p] = 1;
	for (int i = 1; i <= n; i++){
		if (a[i] == 0){
			while (u[p] == 1) p++;
			/*if (p > n){
				cout << -1 << endl;
				return 0;
			}*/
			a[i] = p;
			u[p] = 1;
		}
	}

	for (int i = 1; i <= n; i++){
		b[i] = a[i];
	}

	memset(u, 0, sizeof(u));
	memset(fen, 0, sizeof(fen));

	for (int i = 1; i <= m; i++){
		if (u[x[i]] == 0){
			up(1, 1);
			u[x[i]] = i;
			continue;
		}

		int p = get(u[x[i]]) - (u[x[i]] - 1) + 1;
		up(u[x[i]] + 1, 1);

		if (p != y[i]){
			if (n == 1000000) cout << " " << p << " " << y[i] << " " << u[x[i]] << " " << i << endl;
			cout << -1 << endl;
			return 0;
		}

		u[x[i]] = i;
	}

	for (int i = 1; i <= n; i++){
		printf("%d", b[i]);
		if (i < n) printf(" "); else cout << endl;
	}

    //system("pause");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e6;

const int LIM = 100;

namespace Treap {
  struct Node {
    int val;
    int order;
    int cnt;
    Node *left, *right;
    bool vis;
  };

  typedef Node* NodeP;

  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  Node mem[2 * MAXN + 7];
  int last = 0;
  deque<NodeP> trash_bin;

  NodeP new_node(int val) {
    NodeP temp;

    if (trash_bin.size() > 0) {
      temp = trash_bin.back();
      trash_bin.pop_back();
    }
    else {
      mem[last].order = uniform_int_distribution<int>(0, 1e9)(rng);
      temp = &mem[last];
      last++;
    }

    temp->val = val;
    temp->cnt = 1;
    temp->left = NULL;
    temp->right = NULL;
    temp->vis = false;
    return temp;
  }

  void delete_node(NodeP temp) {
    trash_bin.push_back(temp);
  }

  int cnt(NodeP t) {
    if (!t) {
      return 0;
    }
    return t->cnt;
  }

  void update_cnt(NodeP t) {
    if (t) {
      t->cnt = cnt(t->left) + 1 + cnt(t->right);
    }
  }

  void split(NodeP t, NodeP &l, NodeP &r, int x, int add) {
    if (t == NULL) {
      l = NULL;
      r = NULL;
    }
    else {
      int key = add + 1 + cnt(t->left);
      if (key >= x) {
        split(t->left, l, t->left, x, add);
        r = t;
        update_cnt(r);
      }
      else {
        split(t->right, t->right, r, x, add + 1 + cnt(t->left));
        l = t;
        update_cnt(l);
      }
    }
  }

  void merge(NodeP &t, NodeP l, NodeP r) {
    if (l == NULL) {
      t = r;
    }
    else if (r == NULL) {
      t = l;
    }
    else {
      if (l->order > r->order) {
        merge(l->right, l->right, r);
        t = l;
      }
      else {
        merge(r->left, l, r->left);
        t = r;
      }
    }
    update_cnt(t);
  }

  void insert(NodeP &t, NodeP x, int xkey, int add) {
    if (t == NULL) {
      t = x;
    }
    else {
      int key = add + 1 + cnt(t->left);
      if (key > xkey) {
        insert(t->left, x, xkey, add);
      }
      else if (key < xkey) {
        insert(t->right, x, xkey, add + 1 + cnt(t->left));
      }
      else {
        split(t, x->left, x->right, xkey - add, 0);
        t = x;
      }
    }
    update_cnt(t);
  }

  void erase(NodeP &t, int xkey, int add) {
    if (t != NULL) {
      int key = add + 1 + cnt(t->left);
      if (key == xkey) {
        NodeP temp = t;
        merge(t, t->left, t->right);
        delete_node(temp);
      }
      else if (key > xkey) {
        erase(t->left, xkey, add);
      }
      else {
        erase(t->right, xkey, add + 1 + cnt(t->left));
      }
    }
    update_cnt(t);
  }

  int calc(NodeP t, int len) {
    if (t) {
      return max(calc(t->left, len + 1), calc(t->right, len + 1));
    }
    return len;
  }
};

Treap::NodeP root = NULL;

void add(int x, int y) {
  Treap::NodeP temp = Treap::new_node(y);
  Treap::insert(root, temp, x, 0);
}

bool numbers[MAXN + 7];
int last = 1;

bool move(int x, int y) {
  if (root != NULL) {
    Treap::NodeP t = root;
    while (t->left != NULL) {
      t = t->left;
    }
    if (numbers[y] == true and t->val != y) {
      return false;
    }
    else if (numbers[y] == false and t->val != -1) {
      return false;
    }
  }
  Treap::erase(root, 1, 0);
  Treap::NodeP temp = Treap::new_node(y);
  Treap::insert(root, temp, x, 0);
  numbers[y] = true;
  return true;
}

vector<int> ans_vec;

void print() {
  stack<Treap::NodeP> st;
  st.push(root);
  while (st.size() > 0) {
    Treap::NodeP t = st.top();
    t->vis = true;
    if (t->left and t->left->vis == false) {
      st.push(t->left);
      continue;
    }
    st.pop();
    if (t->val != -1) {
      printf("%d ", t->val);
    }
    else {
      while (numbers[last] == true) {
        last++;
      }
      ans_vec.push_back(last);
      last++;
    }
    if (t->right) {
      st.push(t->right);
    }
  }
}

int x[MAXN + 7];
int y[MAXN + 7];

int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    add(i, -1);
  }

  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x[i], &y[i]);
  }
  for (int i = m; i >= 1; i--) {
    if (!move(y[i], x[i])) {
      printf("-1\n");
      return 0;
    }
    // assert(Treap::calc(root, 0) <= LIM);
  }

  print();

  for (vector<int>::iterator it = ans_vec.begin(); it != ans_vec.end(); it++) {
    printf("%d ", *it);
  }

  return 0;
}

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <float.h>

using namespace std;

#define REP(i, from, to) for (int i = (from); i < (to); ++i)
#define FOR(i, n) REP(i, 0, (n))
#define ALL(x) x.begin(), x.end()
#define SIZE(x) (int)x.size()
#define PB push_back
#define MP make_pair

typedef long long i64;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef pair<int, int> PII;

vector<int> t;
int n;

void init (int nn)
{
    n = nn;
    t.assign (n, 0);
}

int sum (int r)
{
    int result = 0;
    for (; r >= 0; r = (r & (r+1)) - 1)
        result += t[r];
    return result;
}

void inc (int i, int delta)
{
    for (; i < n; i = (i | (i+1)))
        t[i] += delta;
}

int sum (int l, int r)
{
    return sum (r) - sum (l-1);
}

void init (vector<int> a)
{
    init ((int) a.size());
    for (unsigned i = 0; i < a.size(); i++)
        inc (i, a[i]);
}

int findIndex(int index) {
    int l = 0, r = index;
    while (l < r) {
        int const m = (l + r) >> 1;
        int const count = sum(0, m);
        if (count < index)
            l = m + 1;
        else
            r = m;
    }

    return l;
}

int main() {
    //freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(false);

    int size, m;
    cin >> size >> m;

    int const origSize = size;
    n = size;
    init(n);
    FOR (i, n) inc(i, 1);

    VI index(size);
    VI state(2 * size + 100);

    VI position(origSize + 10, -1);

    FOR (i, m) {
        int x, y;
        cin >> x >> y;

        int const needIndex = origSize - y + 1;
        int const whereIndex = findIndex(needIndex);

        //cout << "needIndex = " << needIndex << endl;
        //cout << "whereIndex = " << whereIndex << endl;
        //cout << position[x] << endl;
        int const whatThere = state[whereIndex];
        if (whatThere && whatThere != x || position[x] != -1 && origSize - sum(0, position[x]) != needIndex) {
            cout << "-1\n";
            return 0;
        }

        inc(whereIndex, -1);
        ++size; ++n;
        state[size] = x;
        inc(size, 1);
        position[x] = size;

        if (whereIndex < origSize) {
            index[origSize - whereIndex - 1] = x;
            //cout << "write to " << origSize - whereIndex - 1 << ", x = " << x << endl;
        }
    }

    set<string> notUsed;
    FOR (i, origSize) {
        ostringstream oss;
        oss << i + 1;
        notUsed.insert(oss.str());
    }
    FOR (i, origSize) if (index[i]) {
            ostringstream oss;
            oss << index[i];
            notUsed.erase(oss.str());
    }

    FOR (i, origSize) {
        if (i) cout << " ";
        if (!index[i]) {
            index[i] = atoi((*notUsed.begin()).c_str());
            notUsed.erase(notUsed.begin());
        }
        cout << index[i];
    }

    cout << endl;

    return 0;
}

#define _CRT_DISABLE_PERFCRIT_LOCKS
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <random>
#include <ctime>

using namespace std;

int INF = 1e9;

struct Node {
    int y, val, size, num;
    Node *left, *right;

    Node(int x, int y) {
        num = y;
        val = x;
        y = rand();
        size = 1;
        left = nullptr;
        right = nullptr;
    }

    Node() {
        if (left) delete left;
        if (right) delete right;
    }
};

int get_size(Node *root) {
    if (!root) return 0;
    return root->size;
}

int &get_elem(Node *root, int k) {
    int s1 = get_size(root->left);
    if (s1 == k) {
        return root->val;
    } else if (k < s1) {
        return get_elem(root->left, k);
    } else {
        return get_elem(root->right, k - s1 - 1);
    }
}

int get_elem2(Node *root, int k) {
    int s1 = get_size(root->left);
    if (s1 == k) {
        return root->val;
    } else if (k < s1) {
        return get_elem(root->left, k);
    } else {
        return get_elem(root->right, k - s1 - 1);
    }
}

pair<int, int> getelem(Node *root, int k) {
    int s1 = get_size(root->left);
    if (s1 == k) {
        return {root->val, root->num};
    } else if (k < s1) {
        return getelem(root->left, k);
    } else {
        return getelem(root->right, k - s1 - 1);
    }
}

void update(Node *root) {
    if (!root) return;
    root->size = get_size(root->left) + get_size(root->right) + 1;
}

pair<Node *, Node *> split(Node *root, int key) {
    if (!root) return {nullptr, nullptr};
    int s1 = get_size(root->left), s2 = get_size(root->right);
    if (s1 >= key) {
        auto[root1, root2] = split(root->left, key);
        root->left = root2;
        update(root);
        return {root1, root};
    } else {
        auto[root1, root2] = split(root->right, key - s1 - 1);
        root->right = root1;
        update(root);
        return {root, root2};
    }
}

Node *merge(Node *root1, Node *root2) {
    if (!root1) return root2;
    if (!root2) return root1;
    if (root1->y > root2->y) {
        root1->right = merge(root1->right, root2);
        update(root1);
        return root1;
    } else {
        root2->left = merge(root1, root2->left);
        update(root2);
        return root2;
    }
}

Node *pb(Node *root, int x, int i) {
    Node *t = new Node(x, i);
    root = merge(root, t);
    return root;
}

int next(vector<bool> &mp, int now) {
    for (int i = now; true; i++) {
        if (!mp[i]) return i;
    }
}

bool comp(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

void print(Node *root, vector<bool> &used, int &now){
    if(!root) return;
    print(root->left, used, now);
    if(root->val == INF){
        cout << now << " ";
        now = next(used, now + 1);
    } else{
        cout << root->val;
    }
    print(root->right, used, now);
}

int main() {
    srand(time(0));
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, m;
    cin.sync_with_stdio (false);
    cout.sync_with_stdio (false);
    cin.tie (nullptr);
    cin >> n >> m;
    Node *root = nullptr;
    for (int i = 0; i < n; i++) {
        root = pb(root, INF, i);
    }
    vector<bool> used(n + 1, 0);
    vector<pair<int, int>> q;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        q.push_back({a, b});
    }
    reverse(q.begin(), q.end());
    for (auto i : q) {
        auto [a, b] = i;
        int& x = get_elem(root, 0);
        if((x != a && x != INF)||(x == INF && used[a])){
            cout << -1;
            return 0;
        }
        x = a;
        auto [root1, root23] = split(root, 1);
        auto [root2, root3] = split(root23, b - 1);
        root = merge(merge(root2, root1), root3);
        used[a] = 1;
    }
    int now = next(used, 1);
    print(root, used, now);
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

const int MAXN = 1000000;
int n, t[4*MAXN];
void build (int a[], int v, int tl, int tr) {
    if (tl == tr)
        t[v] = a[tl];
    else {
        int tm = (tl + tr) / 2;
        build (a, v*2, tl, tm);
        build (a, v*2+1, tm+1, tr);
    }
}

void update (int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        t[v] += add;
    else {
        int tm = (tl + tr) / 2;
        update (v*2, tl, tm, l, min(r,tm), add);
        update (v*2+1, tm+1, tr, max(l,tm+1), r, add);
    }
}

int get (int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get (v*2, tl, tm, pos);
    else
        return t[v] + get (v*2+1, tm+1, tr, pos);
}

struct item {
    int prior, cnt;
    int pos;
    int was;
    ll key;
    item * l, * r;
    item() : l(nullptr), r(nullptr), cnt(0) { }
    item (int key, int prior) : key(key), prior(prior), l(nullptr), r(nullptr), cnt(0){ }
};
typedef item * pitem;

int cnt (pitem t) {
    return t ? t->cnt : 0;
}

//void push (pitem it) {
//    if (it && it->add) {
//        if (it->l)  it->l->add = it->add;
//        if (it->r)  it->r->add = it->add;
//        it->add = 0;
//    }
//}

void upd_cnt (pitem t) {
    if (t)
        t->cnt = 1 + cnt(t->l) + cnt (t->r);
}

void upd_all (pitem t) {
    upd_cnt(t);
}

void merge (pitem & t, pitem l, pitem r) {
    if (!l || !r)
        t = l ? l : r;
    else if (l->prior > r->prior /*|| (l->prior == r->prior && rand()%2)*/)
        merge (l->r, l->r, r),  t = l;
    else
        merge (r->l, l, r->l),  t = r;
    upd_all (t);
}

void split (pitem t, pitem & l, pitem & r, ll key, int add = 0) {
    if (!t)
        return void( l = r = 0 );
    // int cur_key = add + cnt(t->l);
    if (key < t->key )//|| (key==t->key && rand()%2))
        split (t->l, l, t->l, key, add),  r = t;
    else
        split (t->r, t->r, r, key, add),  l = t;
    upd_all (t);
}

void insert (pitem & t, pitem it) {
    if (!t)
        t = it;
    else if (it->prior > t->prior /*|| (it->prior == t->prior && rand()%2)*/)
        split (t, it->l, it->r, it->key),  t = it;
    else {
        //if (it->key == t->key && rand() % 2) insert(t->l, it);
        //else
            insert (it->key < t->key ? t->l : t->r, it);
    }
    upd_all (t);
}

void erase (pitem & t, ll key) {
    if (t->key == key)
        merge (t, t->l, t->r);
    else
        erase (key < t->key ? t->l : t->r, key);
    upd_all (t);
}

//pitem unite (pitem l, pitem r) {
//    if (!l || !r)  return l ? l : r;
//    if (l->prior < r->prior)  swap (l, r);
//    pitem lt, rt;
//    split (r, lt, rt, l->key);
//    l->l = unite (l->l, lt);
//    l->r = unite (l->r, rt);
//    return l;
//}

//void add (pitem t, int l, int r) {
//    pitem t1, t2, t3;
//    split (t, t1, t2, l);
//    split (t2, t2, t3, r-l+1);
//    t2->rev ^= true;
//    merge (t, t1, t2);
//    merge (t, t, t3);
//}

pitem search (pitem t, ll key) {
    if(t==nullptr) return nullptr;
    if (t->key < key) {
        t->r->pos = t->pos + 1;
        if(t->l != nullptr) t->r->pos += t->l->cnt;
        return search(t->r, key);
    }
    else if (t->key > key) {
        t->l->pos = t->pos;
        return search(t->l, key);
    }
    else {
        if(t->l != nullptr) t->pos += t->l->cnt;
        return t;
    }
}

int dp;
pitem find_ind(pitem t, int ind) {
    if(ind < cnt(t->l)) {
        dp++;
        return find_ind(t->l, ind);
    }
    else if(ind > cnt(t->l)) {
        dp++;
        return find_ind(t->r, ind - cnt(t->l) - 1);
    }
    else return t;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    int n,m;

    scanf("%d %d", &n, &m);
    vi ans(n,-1);
    vi a(n);
    forn(i,0,n) a[i]=i;
    build(a.data(),1,0,n-1);
    int pr = 0;
    vi where(n,-1);
    int cur = 0;
    std::vector<int> prior;
    for (int i=0; i<n; ++i) prior.push_back(i);
    std::random_shuffle (all(prior));
    vector<item> items(n);
    vi p(n,0);
    pitem root(nullptr);
    forn(i,0,n) {
        items[i].key = i+1;
        items[i].was = i;
        items[i].prior = prior[i];
        items[i].cnt = 0;
        insert(root, &items[i]);
    }

    forn(i,0,m) {

        int x,y;
        scanf("%d %d", &x, &y);
        x--; y--;
        dp = 1;
        pitem r = find_ind(root, y);
        if(m>100000) {
            if(i%100 == 0) cout<<i << " dp " << dp <<endl;
            if(i==4000) return 0;
        }
        if (where[x] >= 0 || ans[r->was] >= 0) {
            if (where[x] != r->was || x != ans[r->was]) {
                cout<<-1;
                return 0;
            }
        }
        else {
            where[x] = r->was;
            ans[r->was] = x;
            p[x] = r->key;
        }
        int u = r->was;
        erase(root, p[x]);
        p[x] = -cur;
        cur++;
        items[u].cnt = 0;
        //items[u].prior = prior[cur];
        //items[u].prior = rand() % (n);
        items[u].key = p[x];
        items[u].l = nullptr;
        items[u].r = nullptr;
        insert(root, &items[u]);

//        if(y>=pr) {
//
//            // ne trogali
//            if(where[x] >= 0) {
//                cout<<-1;
//                return 0;
//            }
//            int st = get(1,0,n-1,y);
//            ans[st] = x;
//            where[x] = st;
//            p[x] = -cur;
//            items[x].prior = prior[cur];
//            items[x].key=p[x];
//            items[x].cnt = 0;
//            insert(root, &items[x]);
//            cur++;
//            pr++;
//            update (1, 0, n-1, pr, y, -1);
//        }
//        else {
//            if(where[x]==-1) {
//                cout<<-1;
//                return 0;
//            }
//            root->pos = 0;
//            pitem test = search(root, p[x]);
//            if(test==nullptr) {
//                cout<<"I AM KILL";
//                return 0;
//            }
//            if(test->pos != y) {
//                cout<<-1;
//                return 0;
//            }
//            erase(root, p[x]);
//            p[x] = -cur;
//            items[x].cnt = 0;
//            items[x].prior = prior[cur];
//            items[x].key=p[x];
//            items[x].l = nullptr;
//            items[x].r = nullptr;
//            insert(root, &items[x]);
//            cur++;
//        }
    }
    vi free;
    forn(i,0,n) if(where[i]==-1) free.pb(i);
    int pc = 0;
    forn(i,0,n) {
        if(ans[i] == -1) {
            ans[i] = free[pc];
            pc++;
        }
    }
    forn(i,0,n) printf("%d ", 1+ans[i]);

}

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(x) (int)x.size()
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N=1010101;
int n,m;
int ans[N], pre[N], cnt[N];
bool vis[N];
pii a[N];

void upd(int p, int c) {
	for(int i=p;i<=n;i+=(i&-i)) cnt[i]+=c;
}
int qry(int p) {
	int res=0;
	for(int i=p;i;i-=(i&-i)) res+=cnt[i];
	return res;
}

int main() {
	while(~scanf("%d%d",&n,&m)) {
		///init
		memset(ans,0,sizeof(ans));
		memset(pre,0,sizeof(ans));
		memset(vis,0,sizeof(vis));
		memset(cnt,0,sizeof(cnt));
		///read
		rep(i,1,m+1) {
			int x, y;scanf("%d%d",&x,&y);
			a[i]=mp(x, y);
		}
		///solve
		bool ok=1;
		rep(i,1,m+1) {
			int x=a[i].fi, y=a[i].se;
			if(pre[x]) {
				if(y!=i-pre[x]) {
					ok=0;
					break;
				}
			} else {
				int c=qry(n)-qry(y-1);
				if(y<=c||ans[y-c]) {
					ok=0;
					break;
				} else {
					ans[y-c]=x;
					upd(y, 1);
				}
			}
			pre[x]=i;
			vis[x]=1;
		}
		if(ok) {
			for(int i=1, j=1;i<=n;++i) if(!ans[i]) {
				while(j<=n&&vis[j]) ++j;
				ans[i]=j;
				vis[j]=1;
			}
			rep(i,1,n+1) printf("%d%c",ans[i]," \n"[i==n]);
		} else {
			puts("-1");
		}
	}
	return 0;
}
/*
2 1
2 1

3 2
1 2
1 1

3 3
1 3
2 3
1 3
*/

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

const int maxn = 1e6 + 100;
const int PW = 21;
const int SZ = (1 << PW);
const int LSZ = (1 << (PW - 1) );

struct Node
{
	int x, y, i, add;
	Node() : x(), y(), i(), add() {}
	Node(int x, int y, int i, int add) : x(x), y(y), i(i), add(add) {}
	bool operator < (const Node &A) const // better
	{
		if (y != A.y)
			return y > A.y;
		return i < A.i;
	}
};

Node tree[SZ];

int x[LSZ], y[LSZ];
int prv[LSZ];

int ans[maxn];

void build_tree()
{
	for (int i = 0; i < LSZ; i++)
	{
		tree[i + LSZ] = Node(x[i], y[i], i, 0);
	}
	for (int i = LSZ - 1; i >= 1; i--)
	{
		tree[i] = min(tree[2 * i], tree[2 * i + 1] );
	}
}

void push(int v)
{
	tree[v].y += tree[v].add;
	if (v < LSZ)
	{
		tree[2 * v].add += tree[v].add;
		tree[2 * v + 1].add += tree[v].add;
	}
	tree[v].add = 0;
}
void add(int v, int tl, int tr, int l, int r, int val)
{
	if (l >= tr || r <= tl)
		return;
	push(v);
	if (l <= tl && tr <= r)
	{
		tree[v].add += val;
		return;
	}
	int tm = (tl + tr) / 2;
	add(2 * v, tl, tm, l, r, val);
	add(2 * v + 1, tm, tr, l, r, val);

	push(2 * v);
	push(2 * v + 1);
	tree[v] = min(tree[2 * v], tree[2 * v + 1] );
}

void no()
{
	printf("-1\n");
	exit(0);
}

const int inf = 3e6;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	memset(prv, -1, sizeof prv);
	memset(ans, -1, sizeof ans);

	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d", &x[i], &y[i] );
		x[i]--;

		if (prv[x[i] ] != -1)
		{
			if (y[i] != i - prv[x[i] ] )
				no();
		}
		prv[x[i] ] = i;

		y[i]--;
	}

	build_tree();

	for (int it = 0; it < m; it++)
	{
		push(1);
		int i = tree[1].i;
		if (tree[1].y < 0)
				break;
		ans[tree[1].y] = tree[1].x;

		add(1, 0, LSZ, i, LSZ, -1);
		add(1, 0, LSZ, i, i + 1, -inf);

	}

	int it = 0;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == -1)
		{
			while (prv[it] != -1)
				it++;
			ans[i] = it;
			it++;
		}
		printf("%d ", ans[i] + 1);
	}

	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define n   2000005
#define CH  (ch=getchar())
#define For(i,a,b)  for(int i=a;i<=b;i++)

int     N,M,T,D,A[n],F[n],Ans[n];

int     IN(){
        int x=0,ch;
        for (;CH<'0'||ch>'9';);
        for (;ch>='0'&&ch<='9';CH)  (x*=10)+=ch-'0';
        return  x;
}

void    Add(int x,int k){
        for (;x<=T;x+=x&-x) F[x]+=k;
}
int     Ask(int x){
        int ret=0;  for (;x;x-=x&-x)    ret+=F[x];
        return  ret;
}
int     Kth(int k){
        int ret=0,tot=0;
        for (int i=19;i+1;i--)
        if  (ret+(1<<i)<=T&&tot+F[ret+(1<<i)]<k)
            ret+=1<<i,tot+=F[ret];
        return  ret+1;
}

int     main(){
        N=IN(); M=D=IN();   T=N+M;
        For(i,M+1,T)    Add(i,1);
        For(i,1,M)  {
            int x=IN(),y=IN(),k;
            if  (!A[x]){
                if  ((k=Kth(y))<=M) return  puts("-1"),0;
                Ans[k-M]=x; A[x]=k;
            }
            if  (Ask(A[x])!=y)  return  puts("-1"),0;
            Add(A[x],-1);   Add(A[x]=D--,1);
        }
        for (int i=1,j=1;i<=N;i++)  if  (!A[i]){
            for (;Ans[j];j++);  Ans[j++]=i;
        }
        For(i,1,N)  printf("%d ",Ans[i]);
}

//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1000000 + 20;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, q, X[N], Y[N], fen[N], a[N], mark[N], prv[N], Fir[N], last[N], inv[N], b[N], ans[N];
vector<pii> Q[N];

void add(int id, int x){
	id += 10;
	for (; id < N; id += id & (-id)) fen[id] += x;
}

int get(int id){
	id += 10;
	int res = 0;
	for (; id > 0; id -= id & (-id)) res += fen[id];
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> q;
	for (int i = 1; i <= q; i++){
		cin >> X[i] >> Y[i];
		//cout << mark[X[i]] << '\n';
		//cout << last[X[i]] << '\n';
		if (mark[X[i]]){
			prv[i] = last[X[i]];
		//	cout << "YES " << prv[i] << '\n';
			last[X[i]] = i;
			continue;
		}
		prv[i] = 0;
		last[X[i]] = i;
		//cout << last[X[i]] << '\n';
		Fir[i] = i;
		int Z = get(Y[i]);
		if (Y[i] - Z <= 0) return cout << -1, 0;
		Z = Y[i] - Z;
		if (a[Z] != 0) return cout << -1, 0;
		a[Z] = X[i];
		inv[X[i]] = Z;
		add(1, 1);
		add(Y[i] + 1, -1);
		mark[X[i]] = 1;
	}
	int pnt = 1;
	for (int i = 1; i <= n; i++){
	//	cout << a[i] << ' ';
		if (a[i] == 0){
			while (mark[pnt]) pnt++;
			a[i] = pnt;
			inv[pnt] = i;
			mark[pnt] = 1;
		}
	}
//	for (int i = 1; i <= n; i++){
//		cout << a[i] << ' ';
//	}
	memset(fen, 0, sizeof fen);
	for (int i = 1; i <= q; i++){
		if (Fir[i] != 0){
			int Z = get(n) - get(inv[X[Fir[i]]]);
		//	cout << i << ' ' << Z << '\n';
			if (Z + inv[X[Fir[i]]] != Y[Fir[i]]) return cout << -1, 0;
			add(inv[X[Fir[i]]], 1);
		}
	}
	//cout << "YES" << endl;
	//cout << prv[n] << '\n';
	//cout << "YES" << endl;
	for (int i = 1; i <= n; i++) b[i] = prv[i];
	memset(fen, 0, sizeof fen);
	for (int i = 1; i <= n; i++){
		//cout << b[i] << '\n';
		if (b[i] != 0){
			Q[prv[i]].pb({-i, prv[i]});
			Q[i - 1].pb({i, prv[i]});
		}
	}
	for (int i = 1; i <= n; i++){
		add(b[i], 1);
		for (auto u:Q[i]){
		//	cout << u.F << ' ' << u.S << ' ' << get(u.S) << '\n';
			if (u.F < 0){
				ans[-u.F] -= get(u.S);
			}else{
				ans[u.F] += get(u.S);
			}
		}
	}
	for (int i = 1; i <= n; i++){
		if (b[i] != 0){
			if (ans[i] + 1 != Y[i]) return cout << -1, 0;
		}
	}
	for (int i = 1; i <= n; i++) cout << a[i] << ' ';
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

#define sz(v) int(v.size())
//#define endl '\n'
typedef long long ll;
typedef pair<int,int> pii;

const int MAXn = 1e5+5;
int val[MAXn+MAXn];
int tree[MAXn];
int n, m;
bool mark[MAXn];

void inc(int ind, int v = 1) {
	while(ind <= n+m) {
		tree[ind] += v;
		ind += (ind&-ind);
	}
}

int find(int x) {
	int ind = 0;
	for(int i = 21; i >= 0; i--) {
		ind += (1<<i);
		if(ind > n+m || tree[ind] < x)
			ind -= (1<<i);
		else if(tree[ind] == x) {
			if(tree[ind] == tree[ind-1])
				ind -= (1<<i);
		} else
			x -= tree[ind];
		cerr << ind << endl;
	}
	return ind;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		inc(n+m-i);
/*	for(int i = 0; i <= 5; i++)
		cerr << tree[i] << " ";
	cerr << endl;*/
	memset(val, -1, sizeof(val));
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		int f = find(y);
		if(val[f] != -1 && val[f] != x) {
			cout << -1 << endl;
			return 0;
		}
		val[f] = x;
		mark[x] = true;
		inc(f, -1);
		inc(m-i, 1);
	}
	int p = 1;
	for(int i = 0; i < n; i++) {
		if(val[m+i+1] == -1) {
			while(mark[p]) p++;
			val[m+i+1] = p;
		}
	}
	for(int i = 0; i < n; i++)
		cout << val[m+1+i] << " ";
	cout << endl;

	return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
const int N = 4e6 + 100;
int n, m;

int val[N], used[N], ans[N];

struct fenwick {
	int n, c[N];
	fenwick(int _n = N - 1):n(_n) {
		memset(c, 0, sizeof c);
	}
	void insert(int p) {
		if (p < 0) return ;
		for (; p <= n; ++c[p], p += p & -p);
	}
	int find_by_order(int k) {
		++k;
		int x = 0;
		for (int i = 21; 0 <= i; --i)
			if (x + (1 << i) <= n && c[x + (1 << i)] < k)
				x += 1 << i, k -= c[x];
		return x + 1;
	}
	void erase(int p) {
		for (; p <= n; --c[p], p += p & -p);
	}
} pos;

int main() {

#ifdef lol
	freopen("420D.in", "r", stdin);
#endif

	scanf("%d%d", &n, &m);
	for (int i = m + 1; i <= n + m; ++i)
		pos.insert(i);
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		auto p = pos.find_by_order(y);
		int t = p;
		pos.erase(p);
		if (!val[t]) {
			ans[t - m] = x;
			if (used[x]) return puts("-1"), 0;
			used[x] = true;
			val[m - i + 1] = x;
			t = m - i + 1;
		} else {
			if (val[t] != x) return puts("-1"), 0;
			val[m - i + 1] = val[t];
			t = m - i + 1;
		}
		pos.insert(t);
	}
	int t = 1;
	for (int i = 1; i <= n; ++i)
		if (!ans[i]) {
			while (used[t]) ++t;
			ans[i] = t++;
		}
	for (int i = 1; i <= n; ++i)
		printf("%d ", ans[i]);
	puts("");

	return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FOE(i,a,b) for(int i = (a); i <= (b); i++)
#define REP(i,n) FOR(i,0,n)
#define LL long long
#define CLR(a,b) memset(a,b,sizeof(a))

#define N 2000005

int L[N * 4], R[N * 4], n, m, x, y, used[N], in[N], type[N];
int s[N * 4], w[N * 4];

void init(int x, int l, int r){
    L[x] = l; R[x] = r; s[x] = 0;
    if (l != r){
        int k = (l + r) >> 1;
        init(x * 2, l, k);
        init(x * 2 + 1, k + 1, r);
        s[x] = s[x * 2] + s[x * 2 + 1];
    }
    else {
        w[x] = l;
        if (l > m){
            type[x] = l - m;
            s[x] = 1;
        }
    }
}

void update(int x, int p, int v, int t){
    if (p > R[x] || p < L[x]) return;
    if (L[x] == p && R[x] == p) {s[x] += v; type[x] = t;}
    else {
        update(x * 2, p, v, t);
        update(x * 2 + 1, p, v, t);
        s[x] = s[x * 2] + s[x * 2 + 1];
    }
}

int query(int x, int v){
    if (L[x] == R[x]) return x;
    if (s[x * 2] >= v) return query(x * 2, v);
    else return query(x * 2 + 1, v - s[x * 2]);
}

int main() {
    scanf("%d%d", &n, &m);
    init(1, 1, n + m);
    CLR(in, -1);
    CLR(used, 0);
    int ok = 1;
    FOR(i, 0, m){
        scanf("%d%d", &x, &y);
        int pos = query(1, y), t = type[pos];
        if (in[t] == -1 && used[x] == 0){
            in[t] = x;
            used[x] = 1;
        }
        else if (in[t] == -1 && used[x]) ok = 0;
        else if (in[t] != x) ok = 0;
        update(1, w[pos], -1, 0);
        update(1, m - i - 1, 1, t);
    }

    int st = 1;
    FOE(i, 1, n)
        if (in[i] == -1){
            while (st <= n && used[st] == 1) st++;
            if (st > n) ok = 0;
            used[in[i] = st] = 1;
        }

    if (!ok) printf("-1\n");
    else FOE(i, 1, n) printf("%d%c", in[i], i==n?'\n':' ');

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <ctime>
#define N 1000009
#define INF (-(1<<29))
using namespace std;
int n,m;
int pos[N],va[N];
class node{
public:
    int val;////position
    int fix;
    int sum;
    int mark;
    int pre;
    node *lson;
    node *rson;
    node(int v,int mk,int pr){
        val=v;
        mark=mk;
        fix=rand();
        sum=1;
        pre=pr;
        rson=lson=NULL;
    }
    node(node* cur){
        val=cur->val;
        fix=cur->fix;
        sum=cur->sum;
        mark=cur->mark;
        pre=cur->pre;
        lson=cur->lson;
        rson=cur->rson;
    }
    bool operator < (struct node b)const{
        return val < b.val;
    }
};
class Treap{
public:
    node *Root;
    Treap(){
        Root=NULL;
    }
    void rotate_right(node* cur){
        node xx=*(cur->lson);
        cur->lson=xx.rson;
        xx.rson=(new node(cur));
        *cur=xx;
        update(cur->rson);
        update(cur);
    }
    void rotate_left(node* cur){
        node xx=*(cur->rson);
        cur->rson=xx.lson;
        xx.lson=(new node(cur));
        *cur=xx;
        update(cur->lson);
        update(cur);
    }
    void update(node* cur){
        if(cur==NULL)return;
        int sum=1;
        if(cur->lson!=NULL)sum+=cur->lson->sum;
        if(cur->rson!=NULL)sum+=cur->rson->sum;
        cur->sum=sum;
    }
    void insert(node* root,node* ad){
        if(Root==NULL){
            Root=ad;
        }else if(ad->val < root->val){
            root->sum++;
            if(root->lson==NULL){
                root->lson=ad;
            }else insert(root->lson,ad);
            if(root->lson->fix < root->fix)
                rotate_right(root);
        }else{
            root->sum++;
            if(root->rson==NULL){
                root->rson=ad;
            }else insert(root->rson,ad);
            if(root->rson->fix < root->fix)
                rotate_left(root);
        }
    }
    void pt(node* root){
        if(root==NULL)return;
        pt(root->lson);
        pos[root->pre]=root->mark;
        pt(root->rson);
    }
    node* findkth(node* root,int k){
        int lsum=0;
        if(root->lson!=NULL) lsum=root->lson->sum;
        if(k<=lsum){
            return findkth(root->lson,k);
        }else if(k==lsum+1){
            return root;
        }else{
            return findkth(root->rson,k-lsum-1);
        }
    }
    node* del(node* root,int val){
        if(root==NULL)return root;
        else if(root->val > val){
            root->lson=del(root->lson,val);
        }else if(root->val < val){
            root->rson=del(root->rson,val);
        }else{
            if(root->lson==NULL && root->rson==NULL){
                if(root==Root)Root=NULL;
                root=NULL;
            }else if(root->lson==NULL){
                *(root)=*(root->rson);
            }else if(root->rson==NULL){
                *(root)=*(root->lson);
            }else{
                if(root->lson->fix < root->rson->fix){
                    rotate_right(root);
                    root->rson=del(root->rson,val);
                }else{
                    rotate_left(root);
                    root->lson=del(root->lson,val);
                }
            }
        }
        update(root);
        return root;
    }
};
int main()
{
    //freopen("in.txt","r",stdin);
    srand(time(0));
    Treap treap;
    cin>>n>>m;
    int head=1;
    bool flag=true;
    node *cur=NULL;
    for(int i=1;i<=n;i++){
        cur=new node(i,-1,i);
        va[i]=INF;
        treap.insert(treap.Root,cur);
    }
    for(int i=0,x,y;i<m;i++){
        cin>>x>>y;
        node *cur=treap.findkth(treap.Root,y);
        if(!flag)continue;
        if(cur->mark==-1 || cur->mark==x){
            if(va[x]!=INF && va[x]!=cur->val){
                flag=false;continue;
            }
            node* ad=new node(cur);
            treap.del(treap.Root,ad->val);
            ad->mark=x;
            ad->val=--head;
            va[x]=ad->val;
            treap.insert(treap.Root,ad);
        }else flag=false;
    }
    if(!flag){
        cout<<"-1"<<endl;
    }else{
        treap.pt(treap.Root);
        set<int> s;
        for(int i=1;i<=n;i++)s.insert(i);
        for(int i=1;i<=n;i++)if(pos[i]!=-1)s.erase(pos[i]);
        for(int i=1;i<=n;i++)if(pos[i]==-1){
            pos[i]=*(s.begin());
            s.erase(s.begin());
        }
        for(int i=1;i<=n;i++){
            printf("%d%c",pos[i],(i==n?'\n':' '));
        }
    }
    return 0;
}

#pragma comment(linker,"/STACK:102400000,102400000")
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<fstream>
#include<cmath>
#include<iomanip>
using namespace std;
//#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#define ll long long
#define ull unsigned long long
#define inf 2000000007
//#define mod 1000000007
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define N 1000010
#define pi 3.14159265358979323846
#define DBG(vari) cerr<<#vari<<"="<<(vari)<<endl;
#define FOREACH(i,t) for(typeof(t.begin()) i=t.begin();i!=t.end();i++)

int n,m,f[N<<1],sz,id[N],p[N],use[N],x[N],y[N];
void add(int x,int v)
{
    while(x<=sz)f[x]+=v,x+=x&-x;
}
int find(int w)
{
    if(w==0)return 0;
    int x=0;
    for(int i=21;i>=0;i--)
    {
        int y=x+(1<<i);
        if(y<=sz&&f[y]<w)w-=f[y],x=y;
    }
    return x+1;
}
bool solve()
{
    sz=n+m+1;int i,k;
    for(i=0;i<=sz;i++)f[i]=0;
    memset(p,-1,sizeof(p));
    memset(id,-1,sizeof(id));
    for(i=1;i<=n;i++)add(m+i,1),id[m+i]=i,use[i]=0;
    for(i=0;i<m;i++)
    {
        int pos=find(y[i]);
        int j=id[pos];
        if(p[j]==-1)p[j]=x[i];
        if(p[j]!=x[i])return 0;
        add(pos,-1);
        add(m-i,1);
        id[pos]=-1;id[m-i]=j;
    }
    for(i=1;i<=n;i++)
    if(p[i]+1)
    if(use[p[i]])return 0;
    else use[p[i]]=1;
    for(k=1,i=1;i<=n;i++)
    if(p[i]==-1)
    {
        while(use[k])k++;
        p[i]=k;use[k]=1;
    }
    return 1;
}
int main()
{
    int T,i,j,k,ca=0;
    while(~scanf("%d%d",&n,&m))
    {
        for(i=0;i<m;i++)scanf("%d%d",&x[i],&y[i]);
        if(solve())
        {
            for(i=1;i<=n;i++)printf("%d ",p[i]);
            puts("");
        }
        else puts("-1");
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for (int i=s;i<=t;i++)
#define pi acos(-1)
typedef long long LL;
typedef pair<int,int> PII;
#define repp(i,s,t) for (int i=s;i>=t;i--)
template<class T> T sqr(T x) {return x*x;}
#define debug(x) cerr<<#x"="<<(x)<<endl;
#define pb(x) push_back(x);
#define bit(x) 1 << i
#define ori(x) x-'a'
const int mar = 1000001;
int tree[mar],used[mar],now[mar],seg[mar * 8];
int place[mar], ans[mar];
int times[mar];
int n,x,y,m;
void insert(int k,int x)
{
	while (k <= n)
	{
		tree[k] += x;
		k += k & -k;
	}
}
int query(int k)
{
	int ret = 0;
	while (k)
	{
		ret += tree[k];
		k -= k & -k;
	}
	return ret;
}
void insert(int k,int l,int r,int x,int p)
{
	if (l == r)
	{
		seg[k] = p;
		return;
	}
	int mid = (l + r) >> 1;
	if (x <= mid) insert(k*2,l,mid,x,p);
	else insert(k*2+1,mid+1,r,x,p);
	seg[k] = seg[k*2] + seg[k*2+1];
}
int query(int k,int l,int r,int p)
{
//	cout << k << " " << l << " " << r << " " << p << endl;
	if (l == r) return l;
	int mid = (l + r) >> 1;
	if (seg[k*2] >= p) return query(k*2,l,mid,p);
	else return query(k*2+1,mid+1,r,p-seg[k*2]);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	rep(i,1,n)
	{
		insert(1,1,n,i,1);
		place[i] = -1;
		now[i] = -1;
	}
//	cout << query(1,1,n,10) << endl;
	int cnt = 0;
	rep(__i,1,m)
	{
		scanf("%d%d",&x,&y);
		if (y <= cnt && now[x] == -1)
		{
			puts("-1");
			return 0;
		}
		if (y <= cnt)
		{
			int xx = query(now[x]);
			if (cnt - xx + 1 != y)
			{
				puts("-1");
				return 0;
			}
			insert(now[x], -1);
			insert(__i, 1);
			now[x] = __i;
		}
		else
		{
			if (place[x] > 0)
			{
				puts("-1");
				return 0;
			}

			int xx = query(1,1,n,y - cnt);
			place[x] = xx;
			insert(1,1,n,xx,0);
//			cout << x << " " << place[x] << endl;
			insert(__i, 1);
			now[x] = __i;
			times[y]++;
			cnt++;
		}
	}
	rep(i,1,n) if (place[i] > 0) ans[place[i]] = i;
	int tem = 1;
	rep(i,1,n) if (ans[i] == 0)
	{
		while (place[tem] != -1) tem++;
		ans[i] = tem++;
	}
	rep(i,1,n) printf("%d ",ans[i]);
	puts("");
	fclose(stdin);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool used[1000010];
struct Treap
{
    Treap *l,*r;
    int val,sz;
    Treap(){l=r=NULL;val=0;sz=1;}
};
unsigned int x;
unsigned int ran()
{
    return x=x*0xdefaced+1;
}
void pull(Treap *t)
{
    t->sz=1;
    if(t->l) t->sz+=t->l->sz;
    if(t->r) t->sz+=t->r->sz;
}
Treap *merge(Treap *a,Treap *b)
{
    if(!a||!b) return a?a:b;
    if(ran()%(a->sz+b->sz)<a->sz)
    {
        a->r=merge(a->r,b);
        pull(a);
        return a;
    }
    else
    {
        b->l=merge(a,b->l);
        pull(b);
        return b;
    }
}
int size(Treap *t){return t?t->sz:0;}
void split(Treap *t,Treap *&a,Treap *&b,int k)
{
    if(!t) {a=b=NULL;return ;}
    if(size(t->l)+1<=k)
    {
        a=t;
        split(t->r,a->r,b,k-size(t->l)-1);
        pull(a);
    }
    else
    {
        b=t;
        split(t->l,a,b->l,k);
        pull(b);
    }
}
int n,m;
typedef pair<int,int> P;
P opr[1000010];
int a=0;
void print(Treap *t)
{
    if(t->l) print(t->l);
    if(t->val!=0) cout<<t->val<<' ';
    else
    {
        while(a<=n&&used[a]==1) a++;
        cout<<a<<' ';
        a++;
    }
    if(t->r) print(t->r);
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	memset(used,0,sizeof(used));
	Treap *root=NULL;
	for(int i=0;i<n;i++) root=merge(root,new Treap());
    for(int i=0;i<m;i++) cin>>opr[i].first>>opr[i].second;
    bool f=0;
    for(int i=m-1;i>=0;i--)
    {
        int x=opr[i].first,y=opr[i].second;
        Treap *a,*b,*c;
        split(root,a,b,1);
        split(b,b,c,y-1);
        if((a->val==0&&used[a->val]==0)||a->val==x)
        {
            used[a->val]=1;
            a->val=x;
            root=merge(merge(b,a),c);
        }
        else
        {
            f=1;
            break;
        }
    }
    if(f) cout<<-1<<'\n';
    else
    {
        print(root);
        cout<<'\n';
    }
	return 0;
}

//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1000000 + 20;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, q, X[N], Y[N], fen[N], a[N], mark[N], prv[N], Fir[N], last[N], inv[N], b[N], ans[N];
vector<pii> Q[N];

void add(int id, int x){
	id += 10;
	for (; id < N; id += id & (-id)) fen[id] += x;
}

int get(int id){
	id += 10;
	int res = 0;
	for (; id > 0; id -= id & (-id)) res += fen[id];
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> q;
	for (int i = 1; i <= q; i++){
		cin >> X[i] >> Y[i];
		//cout << mark[X[i]] << '\n';
		//cout << last[X[i]] << '\n';
		if (mark[X[i]]){
			prv[i] = last[X[i]];
		//	cout << "YES " << prv[i] << '\n';
			last[X[i]] = i;
			continue;
		}
		prv[i] = 0;
		last[X[i]] = i;
		//cout << last[X[i]] << '\n';
		Fir[i] = i;
		int Z = get(Y[i]);
		if (Y[i] - Z <= 0) return cout << -1, 0;
		Z = Y[i] - Z;
		if (a[Z] != 0) return cout << -1, 0;
		a[Z] = X[i];
		inv[X[i]] = Z;
		add(1, 1);
		add(Y[i] + 1, -1);
		mark[X[i]] = 1;
	}
	int pnt = 1;
	for (int i = 1; i <= n; i++){
	//	cout << a[i] << ' ';
		if (a[i] == 0){
			while (mark[pnt]) pnt++;
			a[i] = pnt;
			inv[pnt] = i;
			mark[pnt] = 1;
		}
	}
//	for (int i = 1; i <= n; i++){
//		cout << a[i] << ' ';
//	}
	memset(fen, 0, sizeof fen);
	for (int i = 1; i <= q; i++){
		if (Fir[i] != 0){
			int Z = get(n) - get(i);
			//cout << i << ' ' << Z << '\n';
			if (Z + inv[X[Fir[i]]] != Y[Fir[i]]) return cout << -1, 0;
			add(inv[X[Fir[i]]], 1);
		}
	}
	//cout << prv[n] << '\n';
	//cout << "YES" << endl;
	for (int i = 1; i <= n; i++) b[i] = prv[i];
	memset(fen, 0, sizeof fen);
	for (int i = 1; i <= n; i++){
		//cout << b[i] << '\n';
		if (b[i] != 0){
			Q[prv[i]].pb({-i, prv[i]});
			Q[i - 1].pb({i, prv[i]});
		}
	}
	for (int i = 1; i <= n; i++){
		add(b[i], 1);
		for (auto u:Q[i]){
		//	cout << u.F << ' ' << u.S << ' ' << get(u.S) << '\n';
			if (u.F < 0){
				ans[-u.F] -= get(u.S);
			}else{
				ans[u.F] += get(u.S);
			}
		}
	}
	for (int i = 1; i <= n; i++){
		if (b[i] != 0){
			if (ans[i] + 1 != Y[i]) return cout << -1, 0;
		}
	}
	for (int i = 1; i <= n; i++) cout << a[i] << ' ';
	return 0;
}

#include <algorithm>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cassert>
#include <queue>
#include <cstdlib>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <ctime>

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define lli long long int
#define all( gg )	gg.begin(),gg.end()
#define foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define FP( ii,aa,bb ) for( int ii=aa;ii<=bb;ii++ )
#define FM( ii,aa,bb ) for( int ii=aa;ii>=bb;ii-- )

using namespace std;

int n,m,s[2000000],sira[2000000],h[2000000],F[2000000];
int ind,v[2000000];

void update( int time,int val ){
	while( time ){
		F[time] += val;
		time -= time&-time;
	}
}
int query( int time ){
	int res=0;
	while( time<=1000000 ){
		res += F[time];
		time += time&-time;
	}
	return res;
}

int main(){

	ios_base::sync_with_stdio( false );

	cin >> n >> m;

	int x,y,t;

	FP( i,1,m ){
		cin >> x >> y;
		if( s[x]==0 ){
			s[x] = i;
			sira[x] = y-query( 1 );
			h[sira[x]] = 1;
			update( i,1 );
			continue;
		}
		update( s[x],-1 );
		t = query( s[x]+1 );
		if( t+1!=y ){
			cout << -1 << endl;
			return 0;
		}
		s[x] = i;
		update( s[x],1 );
	}

	FP( i,1,n )	if( !h[i] )	v[++ind] = i;
	FP( i,1,n )	if( !sira[i] )	sira[i] = v[ind--];
	FP( i,1,n )	v[sira[i]] = i;
	FP( i,1,n )	cout << v[i] << " ";
	cout << endl;

}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

const int MAXN = 1000000;
int n, t[4*MAXN];
void build (int a[], int v, int tl, int tr) {
    if (tl == tr)
        t[v] = a[tl];
    else {
        int tm = (tl + tr) / 2;
        build (a, v*2, tl, tm);
        build (a, v*2+1, tm+1, tr);
    }
}

void update (int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        t[v] += add;
    else {
        int tm = (tl + tr) / 2;
        update (v*2, tl, tm, l, min(r,tm), add);
        update (v*2+1, tm+1, tr, max(l,tm+1), r, add);
    }
}

int get (int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get (v*2, tl, tm, pos);
    else
        return t[v] + get (v*2+1, tm+1, tr, pos);
}

struct item {
    int prior, cnt;
    int pos;
    int was;
    ll key;
    item * l, * r;
    item() : l(nullptr), r(nullptr), cnt(0) { }
    item (int key, int prior) : key(key), prior(prior), l(nullptr), r(nullptr), cnt(0){ }
};
typedef item * pitem;

int cnt (pitem t) {
    return t ? t->cnt : 0;
}

//void push (pitem it) {
//    if (it && it->add) {
//        if (it->l)  it->l->add = it->add;
//        if (it->r)  it->r->add = it->add;
//        it->add = 0;
//    }
//}

void upd_cnt (pitem t) {
    if (t)
        t->cnt = 1 + cnt(t->l) + cnt (t->r);
}

void upd_all (pitem t) {
    upd_cnt(t);
}

void merge (pitem & t, pitem l, pitem r) {
    if (!l || !r)
        t = l ? l : r;
    else if (l->prior > r->prior || (l->prior == r->prior && rand()%2))
        merge (l->r, l->r, r),  t = l;
    else
        merge (r->l, l, r->l),  t = r;
    upd_all (t);
}

void split (pitem t, pitem & l, pitem & r, ll key, int add = 0) {
    if (!t)
        return void( l = r = 0 );
    // int cur_key = add + cnt(t->l);
    if (key < t->key || (key==t->key && rand()%2))
        split (t->l, l, t->l, key, add),  r = t;
    else
        split (t->r, t->r, r, key, add),  l = t;
    upd_all (t);
}

void insert (pitem & t, pitem it) {
    if (!t)
        t = it;
    else if (it->prior > t->prior || (it->prior == t->prior && rand()%2))
        split (t, it->l, it->r, it->key),  t = it;
    else {
        if (it->key == t->key && rand() % 2) insert(t->l, it);
        else insert (it->key < t->key ? t->l : t->r, it);
    }
    upd_all (t);
}

void erase (pitem & t, ll key) {
    if (t->key == key)
        merge (t, t->l, t->r);
    else
        erase (key < t->key ? t->l : t->r, key);
    upd_all (t);
}

//pitem unite (pitem l, pitem r) {
//    if (!l || !r)  return l ? l : r;
//    if (l->prior < r->prior)  swap (l, r);
//    pitem lt, rt;
//    split (r, lt, rt, l->key);
//    l->l = unite (l->l, lt);
//    l->r = unite (l->r, rt);
//    return l;
//}

//void add (pitem t, int l, int r) {
//    pitem t1, t2, t3;
//    split (t, t1, t2, l);
//    split (t2, t2, t3, r-l+1);
//    t2->rev ^= true;
//    merge (t, t1, t2);
//    merge (t, t, t3);
//}

pitem search (pitem t, ll key) {
    if(t==nullptr) return nullptr;
    if (t->key < key) {
        t->r->pos = t->pos + 1;
        if(t->l != nullptr) t->r->pos += t->l->cnt;
        return search(t->r, key);
    }
    else if (t->key > key) {
        t->l->pos = t->pos;
        return search(t->l, key);
    }
    else {
        if(t->l != nullptr) t->pos += t->l->cnt;
        return t;
    }
}

pitem find_ind(pitem t, int ind) {
    if(ind < cnt(t->l)) {
        return find_ind(t->l, ind);
    }
    else if(ind > cnt(t->l)) {
        return find_ind(t->r, ind - cnt(t->l) - 1);
    }
    else return t;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    int n,m;

    scanf("%d %d", &n, &m);
    vi ans(n,-1);
    vi a(n);
    forn(i,0,n) a[i]=i;
    build(a.data(),1,0,n-1);
    int pr = 0;
    vi where(n,-1);
    int cur = 0;
    std::vector<int> prior;
    for (int i=0; i<m+1000; ++i) prior.push_back(i);
    std::random_shuffle (all(prior));
    vector<item> items(n);
    vi p(n,0);
    pitem root(nullptr);
    forn(i,0,n) {
        items[i].key = i+1;
        items[i].was = i;
        items[i].prior = prior[i];
        items[i].cnt = 0;
        insert(root, &items[i]);
    }

    forn(i,0,m) {
        int x,y;
        scanf("%d %d", &x, &y);
        x--; y--;
        pitem r = find_ind(root, y);
        if (where[x] >= 0 || ans[r->was] >= 0) {
            if (where[x] != r->was || x!=ans[r->was]) {
                cout<<-1;
                return 0;
            }
        }
        else {
            where[x] = r->was;
            ans[r->was] = x;
            p[x] = r->key;
        }
        int u = r->was;
        erase(root, p[x]);
        p[x] = -cur;
        items[u].cnt = 0;
        //items[u].prior = prior[cur];
        items[u].key = p[x];
        items[u].l = nullptr;
        items[u].r = nullptr;
        insert(root, &items[u]);

//        if(y>=pr) {
//
//            // ne trogali
//            if(where[x] >= 0) {
//                cout<<-1;
//                return 0;
//            }
//            int st = get(1,0,n-1,y);
//            ans[st] = x;
//            where[x] = st;
//            p[x] = -cur;
//            items[x].prior = prior[cur];
//            items[x].key=p[x];
//            items[x].cnt = 0;
//            insert(root, &items[x]);
//            cur++;
//            pr++;
//            update (1, 0, n-1, pr, y, -1);
//        }
//        else {
//            if(where[x]==-1) {
//                cout<<-1;
//                return 0;
//            }
//            root->pos = 0;
//            pitem test = search(root, p[x]);
//            if(test==nullptr) {
//                cout<<"I AM KILL";
//                return 0;
//            }
//            if(test->pos != y) {
//                cout<<-1;
//                return 0;
//            }
//            erase(root, p[x]);
//            p[x] = -cur;
//            items[x].cnt = 0;
//            items[x].prior = prior[cur];
//            items[x].key=p[x];
//            items[x].l = nullptr;
//            items[x].r = nullptr;
//            insert(root, &items[x]);
//            cur++;
//        }
    }
    vi free;
    forn(i,0,n) if(where[i]==-1) free.pb(i);
    int pc = 0;
    forn(i,0,n) {
        if(ans[i] == -1) {
            ans[i] = free[pc];
            pc++;
        }
    }
    forn(i,0,n) printf("%d ", 1+ans[i]);

}

//Link : https://codeforces.com/contest/1253

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 2000005
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/

int pen[N];

void update(int ind,int add) {
  while(ind<N) {
    pen[ind] += add;
    ind += ind&(-ind);
  }
}

int query(int ind) {
  int ret = 0;
  while(ind>0) {
    ret = ret + pen[ind];
    ind = ind&(ind-1);
  }
  return ret;
}

pair<int,int> r[N];
bool vis[N];

int getIndex(int y) {
  int sum = 0;
  int ind = 0;
  for(int i=20;i>=0;--i) {
    int nind = ind + (1<<i);
    if(nind<N) {
      int nsum = sum + pen[nind];
      if(nsum<y) {
        sum = nsum;
        ind = nind;
      }
    }
  }
  return ind + 1;
}

int out[N];

void solve() {
  int n,m;
  scanf(" %d %d ", &n,&m);
  int pos = m + 1;
  for(int i=1;i<=n;++i) {
    r[pos+i] = {-1,i};
    update(pos+i,1);
  }
  for(int i=0;i<m;++i) {
    int x,y;
    scanf("%d %d ", &x,&y);
    int ind = getIndex(y);
    if(vis[x]) {
      if(r[ind].first!=x) {
        printf("-1\n");
        return;
      }
    }
    update(ind,-1);
    update(pos,1);
    r[pos] = r[ind];
    r[pos].first = x;
    vis[x] = true;
    --pos;
  }
  int p = 1;
  for(int i=1;i<=n;++i) {
    int ind = getIndex(i);
    if(r[ind].first==-1) {
      while(p<=n) {
        if(vis[p]) {
          ++p;
        } else {
          break;
        }
      }
      r[ind].first = p++;
    }
    out[r[ind].second] = r[ind].first;
  }

  for(int i=1;i<=n;++i) {
    printf("%d ", out[i]);
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
typedef long long LL;
const int maxn=2e6+5;
int pre[maxn],ch[maxn][2],sz[maxn],val[maxn],tot,root;

inline void init()
{
    tot=root=0;
    ch[0][0]=ch[0][1]=sz[0]=0;
    pre[0]=val[0]=0;
}

inline void push_up(int x)
{
    sz[x]=sz[ch[x][0]]+sz[ch[x][1]]+1;
}

inline void newnode(int &x,int v,int fa)
{
    x=++tot;
    pre[x]=fa;
    ch[x][0]=ch[x][1]=0;
    sz[x]=1;
    val[x]=v;
}

//if kind==1 then R_rotate
inline void Rotate(int x,bool kind)
{
    int y=pre[x];
    ch[y][!kind]=ch[x][kind];
    pre[ch[x][kind]]=y;
    pre[x]=pre[y];
    if(pre[x]) ch[pre[x]][ch[pre[x]][1]==y]=x;
    ch[x][kind]=y;
    pre[y]=x;
    push_up(y);
}

inline void Splay(int x,int goal)
{
    while(pre[x]!=goal)
    {
        if(pre[pre[x]]==goal) Rotate(x,ch[pre[x]][0]==x);
        else
        {
            int y=pre[x];
            bool kind=(ch[pre[y]][0]==y);
            if(ch[pre[x]][kind]==x) Rotate(x,!kind),Rotate(x,kind);
            else Rotate(y,kind),Rotate(x,kind);
        }
    }
    push_up(x);
    if(!goal) root=x;
}

void build(int &x,int l,int r,int fa)
{
    if(l>r) return;
    int mid=(l+r)>>1;
    newnode(x,mid,fa);
    build(ch[x][0],l,mid-1,x);
    build(ch[x][1],mid+1,r,x);
}

inline int get_kth(int x,int k)
{
    while(x)
    {
        if(k<sz[ch[x][0]]+1) x=ch[x][0];
        else if(k>sz[ch[x][0]]+1)
        {
            k-=sz[ch[x][0]]+1;
            x=ch[x][1];
        }
        else
        {
            Splay(x,0);
            return x;
        }
    }
    return 0;
}

inline int get_min(int x)
{
    while(ch[x][0]) x=ch[x][0];
    return x;
}

inline void Del_root()
{
    if(ch[root][1])
    {
        int t=get_min(ch[root][1]);
        Splay(t,root);
        ch[t][0]=ch[root][0];
        pre[ch[root][0]]=t;
        root=t;
    }
    else root=ch[root][0];
    pre[root]=0;
    push_up(root);
}

int ans[maxn];
bool used[maxn];
int pos[maxn];

int main()
{
    init();
    int n,m;
    scanf("%d%d",&n,&m);
    build(root,1,n,0);
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        int t=get_kth(root,y);
        int v=val[t];
        if(used[x])
        {
            if(pos[x]!=v)
            {
                puts("-1");
                return 0;
            }
        }
        if(ans[v]&&ans[v]!=x)
        {
            puts("-1");
            return 0;
        }
        ans[v]=x;
        pos[x]=v;
        used[x]=1;
        Del_root();
        t=get_min(root);
        Splay(t,0);
        newnode(ch[root][0],v,root);
        push_up(root);
    }
    for(int j=1,i=1;i<=n;++i) if(!ans[i])
    {
        for(;used[j]&&j<=n;++j);
        ans[i]=j;
        used[j]=1;
    }
    for(int i=1;i<=n;++i) printf("%d ",ans[i]);
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#define LL long long
#define lc (p<<1)
#define rc ((p<<1)+1)
using namespace std;
int n,m,where[1000010],ans[1000010],x,y,pre[1000010];
struct node
{
	int Min,sum;
}tr[4000010];
struct segtree
{
	struct node1
	{
		int flag,sum;
	}tr[4000010];
	void pushdown(int p)
	{
		tr[lc].flag+=tr[p].flag;
		tr[lc].sum+=tr[p].flag;
		tr[rc].flag+=tr[p].flag;
		tr[rc].sum+=tr[p].flag;
		tr[p].flag=0;
	}
	void Insert(int p,int l,int r,int a,int b)
	{
		if (l==a&&r==b)
		{
			tr[p].flag++,tr[p].sum++;return;
		}
		if (tr[p].flag) pushdown(p);
		int mid=(l+r)>>1;
		if (b<=mid) Insert(lc,l,mid,a,b);
		else if (a>=mid) Insert(rc,mid,r,a,b);
		else
		{
			Insert(lc,l,mid,a,mid);Insert(rc,mid,r,mid,b);
		}
	}
	int Get(int p,int l,int r,int x)
	{
		if (l==r-1) return tr[p].sum;
		if (tr[p].flag) pushdown(p);
		int mid=(l+r)>>1;
		if (x+1<=mid) return Get(lc,l,mid,x);return Get(rc,mid,r,x);
	}
}C;
bool vis[1000010];
void read(int &x)
{
	char ch=getchar();int mark=1;for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());if (ch=='-') mark=-1,ch=getchar();
	for(x=0;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-48;x*=mark;
}
void updata(int p)
{
	tr[p].sum=tr[lc].sum+tr[rc].sum;
	tr[p].Min=min(tr[lc].Min,tr[rc].Min);
}
void Build(int p,int l,int r)
{
	if (l==r-1)
	{
		tr[p].sum=0;
		tr[p].Min=n+1;
		return;
	}
	int mid=(l+r)>>1;
	Build(lc,l,mid);Build(rc,mid,r);
	updata(p);
}
int Getpos(int p,int l,int r,int B)
{
	if (l==r-1) return l;
	int mid=(l+r)>>1;
	if (tr[rc].Min==n+1)
	{
		if (mid<=B) return B;
		else return Getpos(lc,l,mid,B);
	}
	if (tr[rc].Min+tr[rc].sum<=B) return Getpos(rc,mid,r,B);
	return Getpos(lc,l,mid,B-tr[rc].sum);
}
int Getsum(int p,int l,int r,int a,int b)
{
	if (l==a&&r==b) return tr[p].sum;
	int mid=(l+r)>>1;
	if (b<=mid) return Getsum(lc,l,mid,a,b);
	if (a>=mid) return Getsum(rc,mid,r,a,b);
	return Getsum(lc,l,mid,a,mid)+Getsum(rc,mid,r,mid,b);
}
void Insert(int p,int l,int r,int x)
{
	if (l==r-1)
	{
		tr[p].Min=l;tr[p].sum=1;return;
	}
	int mid=(l+r)>>1;
	if (x+1<=mid) Insert(lc,l,mid,x);
	else Insert(rc,mid,r,x);
	updata(p);
}
int main()
{
	read(n);read(m);
	bool flag=1;
	Build(1,1,n+1);
	for(int i=1;i<=m;i++)
	{
		read(x);read(y);
		if (!where[x])
		{
			int t=Getpos(1,1,n+1,y);
			pre[x]=i;
			if (!vis[t]&&Getsum(1,1,n+1,t,n+1)+t==y)
			{
				Insert(1,1,n+1,x);
				where[x]=t;
			}
			else
			{
				flag=0;break;
			}
		}
		else
		{
			int t=pre[x]+1;
			C.Insert(1,1,m+1,t,i+1);
			if (C.Get(1,1,m+1,pre[x])==y-1);
			else
			{
				flag=0;break;
			}
			pre[x]=i;
		}
	}
	if (flag)
	{
		for(int i=1;i<=n;i++)
			if (where[i]) ans[where[i]]=i;
		int now=0;
		for(int i=1;i<=n;i++)
			if (ans[i]) printf("%d ",ans[i]);
			else
			{
				now++;
				for(;where[now];now++);
				printf("%d ",now);
			}
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<ctime>

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(a) (int(a.size()))

using namespace std;

typedef struct item * pitem;
typedef long long int int64;
const int inf=1e9+7;

struct item {
    int prior,val,cnt;
    pitem l,r;
    item(int x){val=x,cnt=1,prior=1ll*rand()*rand()%inf,l=0,r=0;}
};
int cnt(pitem it){
    return it?it->cnt:0;
}
void upd_cnt (pitem it){
    if (it)
       it->cnt=cnt(it->l)+cnt(it->r)+1;
}
void merge(pitem &t,pitem l,pitem r){
    if (!l||!r)t=l?l:r;
    else if (l->prior > r->prior)
       merge (l->r,l->r,r),t=l;
    else
       merge (r->l,l,r->l),t=r;
    upd_cnt(t);
}
void split(pitem t,pitem &l,pitem &r,int key,int add=0){
    if (!t)
       return void(l=r=0);
    int cur_key=add+cnt(t->l);
    if (key <= cur_key)
       split (t->l,l,t->l,key,add),r=t;
    else
       split(t->r,t->r,r,key,add+1+cnt(t->l)),l=t;
    upd_cnt(t);
}
bool puton(pitem t,int key,int add,int x){
    int cur_key=add+cnt(t->l);
    if(key==cur_key){
        if(t->val==-1 || t->val==x){
            t->val=x;return 1;
        }
        else return 0;
    }
    if(key < cur_key)
        return puton(t->l,key,add,x);
    else return puton(t->r,key,add+1+cnt(t->l),x);
}

pair<int,int> q[1111111];
set<int> un;

void go(pitem t){
    if(!t)return;
    if(t->val==-1){
        t->val=*un.begin();
        un.erase(un.begin());
    }
    go(t->l);
    go(t->r);
}

void go2(pitem t){
    if(!t)return;
    go2(t->l);
    cout<<t->val<<' ';
    go2(t->r);
}
bool norm=1;
bool was[1111111];
void go3(pitem t){
    if(!t)return;
    go3(t->l);
    if(was[t->val])norm=0;was[t->val]=1;//cout<<t->val<<' ';
    go3(t->r);
}

int main(){
    ios_base::sync_with_stdio(0);
    srand(time(NULL));
    int n,m;
    cin>>n>>m;
    pitem t=0;
    for(int i=1;i<=n;++i)
        merge(t,t,new item(-1)),un.insert(i);

    for(int i=1;i<=m;++i){
        cin>>q[i].F>>q[i].S;q[i].S--;
        if(un.count(q[i].F))un.erase(q[i].F);
        if(!puton(t,q[i].S,0,q[i].F)){
            cout<<-1;return 0;
        }
        pitem t1,t2,t3;
        split(t,t1,t2,q[i].S+1);
        split(t1,t1,t3,q[i].S);

        merge(t1,t3,t1);
        merge(t,t1,t2);
    }
    go(t);
    for(int i=m;i>=1;--i){
        if(!puton(t,0,0,q[i].F)){
            cout<<-1;return 0;
        }
        pitem t1,t2,t3;
        split(t,t1,t2,1);
        split(t2,t2,t3,q[i].S);

        merge(t2,t2,t1);
        merge(t,t2,t3);
    }
    go3(t);
    if(!norm)cout<<-1;
    else go2(t);

    return 0;
}

#include<cstdio>
#include<ctime>
#include<algorithm>
#include<set>
#include<iostream>
using namespace std;
const int M = 3000005;
const int N = 1000005;
#define lc(x) tree[x].lc
#define rc(x) tree[x].rc
#define v(x) tree[x].v
#define sz(x) tree[x].sz
#define key(x) tree[x].key
#define add(x) tree[x].add
#define id(x) tree[x].id
#define mp(x,y) make_pair(x,y)
typedef pair<int,int> per;
struct P
{
    int lc,rc,v,sz,key,add,id;
}tree[M];
int root,len;
char s[M];
int newnode(int v,int dd)
{
    int id=++len;
    v(id)=v;
    id(id)=dd;
    key(id)=rand();
    sz(id)=1;
    return id;
}
void down(int x)
{
    if(add(x))
    {
        v(x)+=add(x);
        add(lc(x))+=add(x);
        add(rc(x))+=add(x);
        add(x)=0;
    }
}
void up(int x)
{
    sz(x)=sz(lc(x))+sz(rc(x))+1;
}
per split(int x,int n)
{
    if(!n)return mp(0,x);
    if(sz(x)==n)return mp(x,0);
    down(x);
    int cnt=sz(lc(x));
    if(cnt>=n)
    {
        per tp=split(lc(x),n);
        lc(x)=tp.second;
        up(x);
        return mp(tp.first,x);
    }
    else
    {
        per tp=split(rc(x),n-cnt-1);
        rc(x)=tp.first;
        up(x);
        return mp(x,tp.second);
    }
}
int merge(int l,int r)
{
    if(!l||!r)return l+r;
    if(key(l)<=key(r))
    {
        down(l);
        rc(l)=merge(rc(l),r);
        up(l);
        return l;
    }
    else
    {
        down(r);
        lc(r)=merge(l,lc(r));
        up(r);
        return r;
    }
}
void insert(int k,int v,int id)
{
    per tp=split(root,k);
    add(tp.first)--;
    int nw=newnode(v,id);
    root=merge(tp.first,nw);
    root=merge(root,tp.second);
}
void del(int k)
{
    per tp=split(root,k-1);
    add(tp.first)++;
    per tpp=split(tp.second,1);
    root=merge(tp.first,tpp.second);
}
int kd;
int kth(int x,int v)
{
    if(!x)return 0;
    down(x);
    if(v(x)==v){kd+=sz(lc(x));return id(x);}
    if(v(x)>v)return kth(lc(x),v);
    kd+=sz(lc(x))+1;
    return kth(rc(x),v);
}
int r[N];
void dfs(int x)
{
    if(!x)return ;
    down(x);
    r[v(x)]=id(x);
    dfs(lc(x));
    dfs(rc(x));
}
bool u[N];
int A[N],B[N],c[N];
int lowbit(int x)
{
    return x&(-x);
}
int getsum(int x)
{
    int r=0;
    while(x>0)
    {
        r+=c[x];
        x-=lowbit(x);
    }
    return r;
}
void up(int x,int v)
{
    while(x<N)
    {
        c[x]+=v;
        x+=lowbit(x);
    }
}
int main()
{
    srand(time(NULL));
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        kd=0;
        int v=kth(root,b);
        //printf("v:%d kd:%d \n",v,kd);
        if((!u[a]&&v)||(u[a]&&v!=a)){puts("-1");return 0;}
        if(v){del(kd+1);}
        else add(root)++;
        if(!u[a])
        {
            int add=getsum(n+1-b);
            r[b-add]=a;
        }
        up(n+1-b,1);
        //printf("v:%d a:%d b:%d n+1-b:%d \n",v,a,b,n+1-b);
        insert(0,1,a);
        u[a]=true;
    }
    /*for(i=m-1;i>=0;i--)
    {
        del(1);
        kd=0;
        kth(root,B[i]+1);
        insert(kd,B[i],A[i]);
    }
    dfs(root);*/
    int t=1;
    for(i=1;i<=n;i++)
    {
        if(!r[i]){while(u[t])t++;r[i]=t;t++;}
        printf("%d ",r[i]);
    }
    return 0;
}

#include <iostream>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define X first
#define Y second

using namespace std;

int x[2000000];
int y[2000000];
int n, m;
int fen[2000000];

void up(int v, int val){
	while (v <= n + 1){
		fen[v] += val;
		v = (v | (v + 1));
	}
}

int get(int v){
	int val = 0;
	while (v > 0){
		val += fen[v];
		v = (v & (v + 1)) - 1;
	}
	return val;
}

int u[2000000];

int a[2000000];
int b[2000000];
int q[2000000];

int main(){
	cin >> n >> m;
	int C = 0;
	for (int i = 1; i <= n; i++) up(i, 1);
	for (int i = 1; i <= m; i++){
		scanf("%d%d", &x[i], &y[i]);

		if (u[x[i]] == 1){
			continue;
		}
		u[x[i]] = 1;

		if (y[i]  <= C){
			cout << -1 << endl;
			return 0;
		}

		int lo = 0;
		int hi = n;
		while (lo + 1 < hi){
			int mid = (lo + hi) / 2;
			if (get(mid) >= y[i] - C) hi = mid; else lo = mid;
		}

		int p = hi;
		//cout << p << " " << y[i] - C <<  endl;

		a[p] = x[i];
		C++;

		up(p, -1);
	}

	int p = 0;
	u[p] = 1;
	for (int i = 1; i <= n; i++){
		if (a[i] == 0){
			while (u[p] == 1) p++;
			/*if (p > n){
				cout << -1 << endl;
				return 0;
			}*/
			a[i] = p;
			u[p] = 1;
		}
	}

	for (int i = 1; i <= n; i++){
		b[i] = a[i];
	}

	memset(u, 0, sizeof(u));
	memset(fen, 0, sizeof(fen));

	for (int i = 1; i <= m; i++){
		if (u[x[i]] == 0){
			up(1, 1);
			u[x[i]] = i;
			q[i] = get(i + 1);
			continue;
		}

		int p = get(u[x[i]] + 1) - q[u[x[i]]] + 1;
		q[i] = get(i + 1);
		up(u[x[i]] + 1, 1);

		if (p != y[i]){
			cout << -1 << endl;
			return 0;
		}

		u[x[i]] = i;
	}

	for (int i = 1; i <= n; i++){
		printf("%d", b[i]);
		if (i < n) printf(" "); else cout << endl;
	}

    //system("pause");
    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#define LL long long
#define lc (p<<1)
#define rc ((p<<1)+1)
using namespace std;
int n,m,where[1000010],ans[1000010],x,y,pre[1000010];
struct node
{
	int Min,sum;
}tr[4000010];
struct segtree
{
	struct node1
	{
		int flag,sum;
	}tr[4000010];
	void pushdown(int p)
	{
		tr[lc].flag+=tr[p].flag;
		tr[lc].sum+=tr[p].flag;
		tr[rc].flag+=tr[p].flag;
		tr[rc].sum+=tr[p].flag;
		tr[p].flag=0;
	}
	void Insert(int p,int l,int r,int a,int b)
	{
		if (l==a&&r==b)
		{
			tr[p].flag++,tr[p].sum++;return;
		}
		if (tr[p].flag) pushdown(p);
		int mid=(l+r)>>1;
		if (b<=mid) Insert(lc,l,mid,a,b);
		else if (a>=mid) Insert(rc,mid,r,a,b);
		else
		{
			Insert(lc,l,mid,a,mid);Insert(rc,mid,r,mid,b);
		}
	}
	int Get(int p,int l,int r,int x)
	{
		if (l==r-1) return tr[p].sum;
		if (tr[p].flag) pushdown(p);
		int mid=(l+r)>>1;
		if (x+1<=mid) return Get(lc,l,mid,x);return Get(rc,mid,r,x);
	}
}C;
bool vis[1000010];
void read(int &x)
{
	char ch=getchar();int mark=1;for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());if (ch=='-') mark=-1,ch=getchar();
	for(x=0;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-48;x*=mark;
}
void updata(int p)
{
	tr[p].sum=tr[lc].sum+tr[rc].sum;
	tr[p].Min=min(tr[lc].Min,tr[rc].Min);
}
void Build(int p,int l,int r)
{
	if (l==r-1)
	{
		tr[p].sum=0;
		tr[p].Min=n+1;
		return;
	}
	int mid=(l+r)>>1;
	Build(lc,l,mid);Build(rc,mid,r);
	updata(p);
}
int Getpos(int p,int l,int r,int B)
{
	if (l==r-1) return l;
	int mid=(l+r)>>1;
	if (tr[rc].Min==n+1)
	{
		if (mid<=B) return B;
		else return Getpos(lc,l,mid,B);
	}
	if (tr[rc].Min+tr[rc].sum<=B) return Getpos(rc,mid,r,B);
	return Getpos(lc,l,mid,B-tr[rc].sum);
}
int Getsum(int p,int l,int r,int a,int b)
{
	if (l==a&&r==b) return tr[p].sum;
	int mid=(l+r)>>1;
	if (b<=mid) return Getsum(lc,l,mid,a,b);
	if (a>=mid) return Getsum(rc,mid,r,a,b);
	return Getsum(lc,l,mid,a,mid)+Getsum(rc,mid,r,mid,b);
}
void Insert(int p,int l,int r,int x)
{
	if (l==r-1)
	{
		tr[p].Min=l;tr[p].sum=1;return;
	}
	int mid=(l+r)>>1;
	if (x+1<=mid) Insert(lc,l,mid,x);
	else Insert(rc,mid,r,x);
	updata(p);
}
int main()
{
	read(n);read(m);
	bool flag=1;
	Build(1,1,n+1);
	for(int i=1;i<=m;i++)
	{
		read(x);read(y);
		if (!where[x])
		{
			int t=Getpos(1,1,n+1,y);
			pre[x]=i;
			if (!vis[t]&&Getsum(1,1,n+1,t,n+1)+t==y)
			{
				Insert(1,1,n+1,t);
				where[x]=t;
			}
			else
			{
				flag=0;break;
			}
		}
		else
		{
			int t=pre[x]+1;
			C.Insert(1,1,m+1,t,i+1);
			if (C.Get(1,1,m+1,pre[x])==y-1);
			else
			{
				flag=0;break;
			}
			pre[x]=i;
		}
	}
	if (flag)
	{
		for(int i=1;i<=n;i++)
			if (where[i]) ans[where[i]]=i;
		int now=0;
		for(int i=1;i<=n;i++)
			if (ans[i]) printf("%d ",ans[i]);
			else
			{
				now++;
				for(;where[now];now++);
				printf("%d ",now);
			}
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define M 2000010
using namespace std;
vector< pair<int, int> > vec[M];
#define ls p<<1
#define rs p<<1|1
#define MP make_pair
#define X first
#define Y second

struct Node
{
	int l, r;
	int cnt, col;
}nde[M<<2];
int xx[M], yy[M];
int n, m;
int pos[M];

void up( int p )
{
	nde[p].cnt = nde[ls].cnt + nde[rs].cnt;
}
void build( int l, int r, int p )
{
	nde[p].l = l, nde[p].r = r;
	nde[p].col = 0;
	if( l >= r ){
		nde[p].cnt = l > m;
		return;
	}
	int m = ( l + r ) >> 1;
	build( l, m, ls );
	build( m+1, r, rs );
	up( p );
}
int find( int p, int k )
{
	if( nde[p].l >= nde[p].r ) return p;
	if( nde[ls].cnt >= k ) return find( ls, k );
	else return find( rs, k - nde[ls].cnt );
}
void update( int k, int p, int flag, int num )
{
	if( nde[p].l >= nde[p].r ){
		nde[p].col = flag;
		nde[p].cnt = num;
		return;
	}
	if( k <= nde[ls].r ) update( k, ls, flag, num );
	else update( k, rs, flag, num );
	up( p );
}
int vis[M];
int solve()
{
	build( 1, m+n, 1 );
	int x, y;
	int lft = m;
	for( int i = 1; i <= m; ++i ){
		x = xx[i], y = yy[i];
		if( x > n ) return 0;
		int p = find( 1, y );
		if( nde[p].col ){
			if( nde[p].col != x ) return 0;
			update( nde[p].l, 1, 0, 0 );
			update( lft--, 1, x, 1 );
		}
		else{
			if( pos[x] && pos[x] != nde[p].l ) return 0;
			pos[x] = nde[p].l;
			update( nde[p].l, 1, 0, 0 );
			update( lft--, 1, x, 1 );
		}
	}
	for( int i = 1; i <= n; ++i ) if( pos[i] )
		vis[pos[i]-m] = 1, pos[i] -= m;
	int k = 1;
	for( int i = 1; i <= n; ++i ) if( !pos[i] ){
		while( vis[k] ) ++k;
		pos[i]= k;
		vis[k] = 1;
	}
	for( int i = 1; i <= n; ++i ) printf( "%d ", pos[i] );
	return 1;
}
int main()
{
	scanf( "%d%d", &n, &m );
	for( int i = 1; i <= m; ++i ) scanf( "%d%d", xx+i, yy+i );
	if( !solve() ) puts( "-1" );
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<ctime>

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(a) (int(a.size()))

using namespace std;

typedef struct item * pitem;
typedef long long int int64;
const int inf=1e9+7;

struct item {
    int prior,val,cnt;
    pitem l,r;
    item(int x){val=x,cnt=1,prior=1ll*rand()*rand()%inf,l=0,r=0;}
};
int cnt(pitem it){
    return it?it->cnt:0;
}
void upd_cnt (pitem it){
    if (it)
       it->cnt=cnt(it->l)+cnt(it->r)+1;
}
void merge(pitem &t,pitem l,pitem r){
    if (!l||!r)t=l?l:r;
    else if (l->prior > r->prior)
       merge (l->r,l->r,r),t=l;
    else
       merge (r->l,l,r->l),t=r;
    upd_cnt(t);
}
void split(pitem t,pitem &l,pitem &r,int key,int add=0){
    if (!t)
       return void(l=r=0);
    int cur_key=add+cnt(t->l);
    if (key <= cur_key)
       split (t->l,l,t->l,key,add),r=t;
    else
       split(t->r,t->r,r,key,add+1+cnt(t->l)),l=t;
    upd_cnt(t);
}
bool puton(pitem t,int key,int add,int x){
    int cur_key=add+cnt(t->l);
    if(key==cur_key){
        if(t->val==-1 || t->val==x){
            t->val=x;return 1;
        }
        else return 0;
    }
    if(key < cur_key)
        return puton(t->l,key,add,x);
    else return puton(t->r,key,add+1+cnt(t->l),x);
}

pair<int,int> q[1111111];
set<int> un;

void go(pitem t){
    if(!t)return;
    if(t->val==-1){
        t->val=*un.begin();
        un.erase(un.begin());
    }
    go(t->l);
    go(t->r);
}

void go2(pitem t){
    if(!t)return;
    go2(t->l);
    cout<<t->val<<' ';
    go2(t->r);
}
bool norm=1;
bool was[1111111];
void go3(pitem t){
    if(!t)return;
    go3(t->l);
    if(was[t->val])norm=0;was[t->val]=1;//cout<<t->val<<' ';
    go(t->r);
}

int main(){
    ios_base::sync_with_stdio(0);
    srand(time(NULL));
    int n,m;
    cin>>n>>m;
    pitem t=0;
    for(int i=1;i<=n;++i)
        merge(t,t,new item(-1)),un.insert(i);

    for(int i=1;i<=m;++i){
        cin>>q[i].F>>q[i].S;q[i].S--;
        if(un.count(q[i].F))un.erase(q[i].F);
        if(!puton(t,q[i].S,0,q[i].F)){
            cout<<-1;return 0;
        }
        pitem t1,t2,t3;
        split(t,t1,t2,q[i].S+1);
        split(t1,t1,t3,q[i].S);

        merge(t1,t3,t1);
        merge(t,t1,t2);
    }

    for(int i=m;i>=1;--i){
        if(!puton(t,0,0,q[i].F)){
            cout<<-1;return 0;
        }
        pitem t1,t2,t3;
        split(t,t1,t2,1);
        split(t2,t2,t3,q[i].S);

        merge(t2,t2,t1);
        merge(t,t2,t3);
    }
    go(t);
    go3(t);
    if(!norm)cout<<-1;
    else go2(t);

    return 0;
}

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<vector>
#define MAXN 1000005
using namespace std ;
typedef long long LL ;

struct point {
	int x, at ;
} s[MAXN] ;

int N, M, head, now ;
int son[MAXN][2], fa[MAXN] ;
int sum[MAXN], num[MAXN] ;
int vis[MAXN] ;

void Update(int x)
{
	sum[x] = sum[son[x][0]]+sum[son[x][1]]+1 ;
}
void Rotate(int x, int d)
{
	int tmp = fa[x] ;
	son[tmp][d^1] = son[x][d], fa[son[x][d]] = tmp ;
	if(fa[tmp]) son[fa[tmp]][son[fa[tmp]][1] == tmp] = x ;
	fa[x] = fa[tmp], fa[tmp] = x, son[x][d] = tmp ;
	Update(tmp), Update(x) ;
}
void Splay(int x, int to)
{
	int tmp, d1, d2 ;
	while((tmp=fa[x]) != to)
	{
		if(fa[tmp] == to) Rotate(x, son[tmp][0]==x) ;
		else if((d1=(son[fa[tmp]][0]==tmp)) == (d2=(son[tmp][0]==x)))
			Rotate(tmp, d1), Rotate(x, d2) ;
		else Rotate(x, d2), Rotate(x, d1) ;
	}
}
void Delete(int x)
{
	Splay(x, 0) ;
	if(!(son[x][0]+son[x][1])) return ;
	if(!son[x][0] || !son[x][1])
	{
		int tmp = (!!son[x][1]) ;
		son[x][tmp] = fa[son[x][tmp]] = 0 ;
		sum[x] = 1 ;
	}
	int l = son[x][0], r = son[x][1] ;
	Splay(l, 0), Splay(r, l) ;
	son[r][0] = fa[x] = 0 ;
	sum[x] = 1, sum[r] --, sum[l] -- ;
}
int Ask(int x, int k)
{
	int tmp = 0 ;
	for(x;x;)
		if(sum[son[x][0]]+1 == k) break ;
		else if(sum[son[x][0]]+1<k)
			k -= sum[son[x][0]]+1, x = son[x][1] ;
		else x = son[x][0] ;
	return x ;
}
void Dfs(int x)
{
	if(son[x][0])
		Dfs(son[x][0]) ;
	if(num[x] == -1)
	{
		while(vis[now]) now ++ ;
		vis[now] = 1, num[x] = now ;
	}
	printf("%d ", num[x]) ;
	if(son[x][1])
		Dfs(son[x][1]) ;
}
void Fail()
{
	printf("-1\n") ;
	//system("pause") ;
	exit(0) ;
}

int main()
{
	int i, j, tmp, lt, rt ;
	int type, fr, to ;
	scanf("%d %d", &N, &M) ;
	for(i = 1; i <= M; i ++)
		scanf("%d %d", &s[i].x, &s[i].at) ;
	head = N, sum[N] = 1, num[N] = -1 ;
	for(i = N-1; i >= 1; i --)
	{
		Splay(head, 0) ;
		son[head][0] = i, fa[i] = head, sum[i] ++, sum[head] ++ ;
		num[i] = -1, head = i ;
	}
	for(i = M; i; i --)
	{
		if(num[head] >= 0 && num[head] != s[i].x) Fail() ;
		num[head] = s[i].x, vis[s[i].x] = 1 ;
		if(s[i].at == 1) continue ;
		else
		{
			Splay(head, 0) ;
			lt = Ask(head, s[i].at) ;
			rt = Ask(head, s[i].at+1) ;
			Delete(head), Splay(lt, 0) ;
			if(rt) {Splay(rt, lt), son[rt][0] = head, fa[head] = rt, sum[lt]++, sum[rt]++ ;}
			else {son[lt][1] = head, fa[head] = lt, sum[lt]++ ;}
		}
	}
	now = 1 ;
	Splay(head, 0), Dfs(head) ;
	//system("pause") ;
	return 0 ;
}

#include <iostream>

#include <cstdlib>
#include <ctime>

using namespace std;

class treap {
    public:
        long long prior, num, cnt;
        treap *l, *r;
}; typedef treap* tree;

int cnt(tree t){
	if (!t)
		return 0;
	return t->cnt;
}

void upd_cnt(tree t){
	if (!t)
		return;
	t->cnt = cnt(t->l) + 1 + cnt(t->r);
}

void split(tree t, int k, tree& l, tree& r) {
    if (!t) {
        l = r = NULL;
        return;
    }
    int tk = cnt(t->l);
    if (k <= tk) {
        split(t->l, k, l, t->l);
        r = t;
    } else {
        split(t->r, k - tk - 1, t->r, r);
        l = t;
    }
    upd_cnt(t);
}

int find(tree t, int k) {
    int tk = cnt(t->l);
    if ( k == tk + 1 )
        return t->num;
    if ( k <= tk )
        return find(t->l, k);
    else
        return find(t->r, k - tk - 1);
}

tree merge(tree l, tree r) {
    if (!r || !l) {
        upd_cnt(l);
        upd_cnt(r);
        return (l ? l : r);
    }
    if (l->prior > r->prior) {
        l->r = merge(l->r, r);
        upd_cnt(l);
        return l;
    } else {
        r->l = merge(l, r->l);
        upd_cnt(r);
        return r;
    }
}

void insert(tree& t, tree it) {
    //tree l, r;
    //split(t, it->num, l, r);
    t = merge(it, t);
}

void get_answer(tree t) {
    if (!t) {
        //cout << "u";
        return;
    }
    //cout << "l";
    get_answer(t->l);
    cout << t->num << ' ';
    //cout << t->num << '(' << cnt(t) << ')';
    //cout << "r";
    get_answer(t->r);
    //cout << "u";
    return;
}

treap nodes[1000010];
bool used[1000010];
int oldpos[1000010];

int main(){
    srand(time(0));
    int last = 0;
    int n, m;
    time_t _time = time(NULL);
    cin >> n >> m;
    tree root = NULL;
    tree tmp = NULL;
    int size = 0;
    int x, y;
    for ( int i = 0; i < m; i++ ) {
        cin >> x >> y;
        oldpos[i] = y;
        if ( y > size ) {
            if ( used[x] ) {
                cout << -1;
                return 0;
            }
            tmp = &nodes[last];
            ++last;
            tmp->l = NULL;
            tmp->r = NULL;
            tmp->prior = (rand() << 15) + rand();
            tmp->num = x;
            //insert(root, tmp);
            root = merge(tmp, root);
            //get_answer(root);
            size++;
        } else if ( find(root, y) != x ) {
            cout << -1;
            return 0;
        } else {
            tree l, r, m;
            split(root, y - 1, l, r);
            split(r, 1, m, r);
            root = merge(m, merge(l, r));
            ///get_answer(root);
        }
        used[x] = true;
    }

    for ( int i = 1; i <= n; i++ )
        if ( !used[i] ) {
            tmp = &nodes[last];
            ++last;
            tmp->l = tmp->r = NULL;
            tmp->prior = (rand() << 15) + rand();
            tmp->num = i;
            root = merge(root, tmp);
        }

    if ( difftime(time(NULL), _time) >= 2 ) {
        cout << "timeproblems";
        return 0;
    }
    //get_answer(root);
    //cout << endl;

    tree l, r, med;
    for ( int i = m - 1; i >= 0; i-- ) {
        //cout << "move " << find(root, 1) << " to " << oldpos[i] << endl;
        split(root, oldpos[i], med, r);
        //get_answer(med);
        //cout << endl;
        split(med, 1, l, med);
        //get_answer(l);
        //cout << endl;
        root = merge(med, merge(l, r));
        //get_answer(root);
        //cout << endl;
    }

    get_answer(root);

    return 0;
}

/*
3 3
3 2
2 2
1 3
*/

/*input
3 3
1 3
2 3
1 3

*/
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define is insert
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define mp make_pair
#define mh make_heap
#define F first
#define S second
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
#define int long long
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;
vi seg_tree;
ll siz,n,m;
vi org_arr;

void update(ll node,ll l,ll r,ll index,ll val)
{
	/*if(l>r)
		return;
	if(l==r && l==index)
	{
		seg_tree[node]=val;
		return ;
	}
	if(index>=l && index<=((l+r)/2))
		update(2*node,l,(l+r)/2,index,val);
	else
		update(2*node+1,1+(l+r)/2,r,index,val);
	seg_tree[node]=seg_tree[2*node]+seg_tree[2*node+1];*/

	index+=siz;
	seg_tree[index]=val;
	for(index/2;index>=1;index/=2)
		seg_tree[index]=seg_tree[2*index]+seg_tree[2*index+1];
}

ll find_sum_index(ll node,ll l,ll r,ll sum)
{
	//cout<<node<<" "<<l<<" "<<r<<" "<<sum<<endl;
	/*if(l>r)
		return 0;
	if(l==r && sum==seg_tree[node])
		return node;
	if(sum<=seg_tree[node*2])
		return find_sum_index(node*2,l,(l+r)/2,sum);
	else
		return find_sum_index(node*2+1,1+(l+r)/2,r,sum-seg_tree[2*node]);*/

	while(l<r)
	{
		if(sum<sum<=seg_tree[node*2])
			{node=node*2;r=(l+r)/2;}
		else
			{node=node*2+1;sum-=seg_tree[2*node];l=1+(l+r)/2;}
	}
	return node;
}

void print()
{
	rep(i,1,seg_tree.size())
	cout<<seg_tree[i]<<" ";
	cout<<endl;
}
void build_seg_tree()
{
	ll hei=ceil(log2(n+m));
	siz=pow(2,hei);

	seg_tree.resize(2*siz);
	org_arr.resize(2*siz,0);
	for(int i=siz;i<siz+m;i++)
		seg_tree[i]=0;
	for(int i=siz+m;i<(siz+m+n);i++)
		seg_tree[i]=1;
	for(int i=siz+m+n;i<2*siz;i++)
		seg_tree[i]=0;
	for(int i=siz-1;i>0;i--)
		seg_tree[i]=seg_tree[2*i]+seg_tree[2*i+1];

	//print();

}

void solve()
{
	cin>>n>>m;
	vi x(n),pos(n);
	fr(m)
	{
		cin>>x[i]>>pos[i];
	}
	build_seg_tree();

	ll values[n+1]={-1};

	ll prev=siz-1;
	fr(m)
	{
		ll find_pos=find_sum_index(1,1,siz,pos[i]);
		if(org_arr[find_pos]==0 || org_arr[find_pos]==x[i])
		{

			org_arr[find_pos]=x[i];
			//ll find_sum1=find_sum_index(1,1,siz,1);
			ll find_sum1=prev;
			//cout<<find_pos<<" "<<find_sum1<<endl;
			org_arr[find_sum1-1]=x[i];
			update(1,1,siz,find_pos-siz+1,0);
			update(1,1,siz,find_sum1-1-siz+1,1);
			prev--;
			//print();
		}
		else
		{
			cout<<-1<<endl;
			return ;
		}
	}

	map<ll,ll> ma;
	vi ans;
	for(int i=siz+m;i<siz+m+n;i++)
	{
		ans.pb(org_arr[i]);
		if(org_arr[i]!=0)
			{
				if(ma[org_arr[i]]==0)
					ma[org_arr[i]]=i-siz-m+1;
				else
					{cout<<-1<<endl;return ;}
			}
	}

	ll j=1;
	fr(ans.size())
	{
		if(ans[i]==0)
		{
			for(j;j<=n;j++)
			{
				if(ma[j]==0)
				{
					ans[i]=j;
					ma[j]=1;
					break;
				}
			}
		}
	}
	fr(ans.size())
	cout<<ans[i]<<" ";
	cout<<endl;

}

int32_t main()
{
	int t=1;
	//cin>>t;
	fr(t)
	solve();
}

#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1000005;
struct St{
	int l, r, sz;
} st[N<<2];

int hav[N], ans[N];
bool vis[N];
void build(int l, int r, int i){
	st[i].l = l;
	st[i].r = r;
	st[i].sz = r-l+1;
	if(l==r) return;
	int mid = (l+r)>>1;
	build(l,mid,i<<1);
	build(mid+1,r,i<<1|1);
}

int find(int whe, int i){
	if(st[i].l == st[i].r){
		st[i].sz = 0;
		return st[i].l;
	}
	int mid = (st[i].l+st[i].r)>>1, res;
	if(whe<=st[i<<1].sz){
		res = find(whe, i<<1);
	}
	else{
		res = find(whe-st[i<<1].sz, i<<1|1);
	}

	st[i].sz = st[i<<1].sz + st[i<<1|1].sz;
	return res;
}

int c[N];
void add(int x, int u){
	for(; x<N; x+=x&-x){
		c[x] += u;
	}
}

int sum(int x){
	int res = 0;
	for(; x; x-=x&-x){
		res += c[x];
	}
	return res;
}

int main(){
	int n, m, head, x, y;
	scanf("%d%d",&n,&m);
	build(1,n,1);
	head = 1000005;

	int now = 0;
	while(m--){
		scanf("%d%d",&x,&y);
		if(hav[x]){
			if(sum(hav[x]) != y) break;
			add(hav[x], -1);
			hav[x] = --head;
			add(head, 1);
		}
		else{
			ans[find(y-now, 1)] = x;
			vis[x] = true;
			hav[x] = --head;
			add(head, 1);
			++now;
		}
	}
	if(m>=0) puts("-1");
	else{
		now = 1;
		for(int i=1;i<=n;++i){
			if(!ans[i]){
				while(vis[now]) ++now;
				printf("%d ", now);
				++now;
			}
			else printf("%d ", ans[i]);
		}
	}
	return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>

using namespace std;

const int maxn=1000000;

int s[maxn*2+1],ch[maxn*2+1][2],o[maxn+1],c[maxn+1],n,m,a,b,tt=0,su[maxn+1];

void reloc()
{
    freopen("/Users/admin/Desktop/cards.in","r",stdin);
    freopen("/Users/admin/Desktop/cards.out","w",stdout);
    return;
}

void buildtree(int l,int r)
{
    if(l>r)return;
    tt++;
    int now=tt;
    s[tt]=0;
    if(l==r)
    {
        ch[tt][0]=ch[tt][1]=0;
        return;
    }
    int mid=(l+r)/2;
    ch[tt][0]=tt+1;
    buildtree(l,mid);
    ch[now][1]=tt+1;
    buildtree(mid+1,r);
    return;
}

int findp(int root, int l,int r,int po)
{

    if(l==r)return l;
    int mid=(l+r)>>1;
    //printf("root=%d evaluation=%d goal=%d\n",root,mid+s[ch[root][1]],po);
    //if(mid+s[ch[root][1]]+((c[mid])&&1)==po)return mid;
    if(mid+s[ch[root][1]]+1>po)return findp(ch[root][0],l,mid,po-s[ch[root][1]]);

    else return findp(ch[root][1],mid+1,r,po);
}

void update(int root,int l,int r,int p)
{

    if(root==0)return;
    if(p<l||r<p)return;
    //printf("root=%d\n",root);
    s[root]++;
    if(l==r)return;
    int mid=(l+r)>>1;
    update(ch[root][0],l,mid,p);
    update(ch[root][1],mid+1,r,p);
    return;
}

void print()
{
    queue<int> q;
    for(int i=1;i<=n;i++)if(o[i]==0)q.push(i);
    for(int i=1;i<n;i++)
    {
        if(c[i]==0)
        {
            printf("%d ",q.front());
            q.pop();
        }
        else
        {
            printf("%d ",c[i]);

        }
    }
    int i=n;
    if(c[i]==0)
    {
        printf("%d\n",q.front());
        q.pop();
    }
    else
    {
        printf("%d\n",c[i]);

    }
    return;

}

int Sum(int k)
{
    int ans=0;
    for(;k>0;k-=(k&(-k)))
    {
        ans+=su[k];
    }
    return ans;
}

int sum(int a,int b)
{
    return Sum(b)-Sum(a-1);

}

void update(int k)
{
    for(;k<=m;k+=(k&(-k)))
    {
        su[k]++;
    }
    return;
}

void read()
{

    memset(c,0,sizeof(c));
    memset(s,0,sizeof(s));
    memset(o,0,sizeof(o));
    memset(ch,0,sizeof(ch));
    memset(su,0,sizeof(su));
    scanf("%d%d",&n,&m);
    buildtree(1,n);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        //cout<<'*'<<a<<endl;
        if(o[a]==0)
        {
            int p=findp(1,1,n,b);
            //cout<<p<<endl;
            update(1,1,n,p);
            o[a]=i;
            if(c[p])
            {
                cout<<-1<<endl;
                return;
            }
            c[p]=a;

        }
        else
        {
            int l=i-o[a]-sum(o[a]+1,i-1);  //inclusive
            //cout<<l<<' '<<sum(o[a]+1,i-1)<<endl;
            update(o[a]);
            o[a]=i;
            if(b!=l)
            {
                cout<<-1<<endl;
                return;
            }
        }
    }
    print();
    return;
}

int main()
{
    //reloc();
    read();
    return 0;
}

#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

const int maxn = 1000005;

struct node
{
    int key,pri,siz,po;
    inline int sonsiz(int x){return ch[x]==NULL?0:ch[x]->siz;}
    node *ch[2];
}*st,*root;

int tot;
node seq[maxn*2];

void rotate(node* &p,int x)
{
    st = p->ch[x];
    p->ch[x] = st->ch[x^1];
    int tmp = st->siz-st->sonsiz(x^1);
    st->siz = p->siz;p->siz -= tmp;
    st->ch[x^1]=p;
    p =st;
}

void inser(node* &p,int x,int a)
{
    if(p==NULL)
    {
        p = &seq[tot++];p->po = a;
        p -> key = x;
        p -> pri = rand();p->siz = 1;
        p ->ch[0] = p->ch[1] = NULL;
        return ;
    }
    p->siz++;
    if(x<p->key)
    {
        inser(p->ch[0],x,a);
        if(p->ch[0]->pri<p->pri)
            rotate(p,0);
    }
    else if(x>p->key)
    {
        inser(p->ch[1],x,a);
        if(p->ch[1]->pri<p->pri)
            rotate(p,1);
    }
}

void del(node* &p,int x)//分叶节点，链节点，完全节点讨论
{
    if(p->key==x)
    {
        if(p->ch[0]==NULL)
            p = p->ch[1];
        else if(p->ch[1]==NULL)
            p = p->ch[0];
        else if(p->ch[0]->pri<p->ch[1]->pri)
        {
            rotate(p,0);p->siz--;
            del(p->ch[1],x);
        }
        else
        {
            rotate(p,1);p->siz--;
            del(p->ch[0],x);
        }
    }
    else if(x<p->key)
    {
        p->siz--;del(p->ch[0],x);
    }
    else
    {
        p->siz--;del(p->ch[1],x);
    }
}

int err;
void query(node* p,int k)
{
    if(p->sonsiz(0)>=k)
        query(p->ch[0],k);
    if(k==p->sonsiz(0)+1)
    {
        err = p->po;
        del(root,p->key);
        return ;
    }
    else
        query(p->ch[1],k-1-p->sonsiz(0));
}
int n,m,val[maxn];
bool vis[maxn];

void run()
{
    int a,b;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        query(root,b);
        if(val[err]&&val[err]!=a)
        {
            puts("-1");
            return ;
        }
        inser(root,-i,err);
        if(val[err]==a)
            continue;
        val[err] = a;
        if(vis[a])
        {
            puts("-1");
            return ;
        }
        vis[a] = 1;
    }
    int pt = 1;
    for(int i=1;i<=n;i++)
    {
        if(val[i])
            printf("%d ",val[i]);
        else
        {
            while(vis[pt])
                pt++;
            printf("%d ",pt);
            pt++;
        }
    }
}
int main()
{
    root = NULL;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        inser(root,i,i);
    run();
}

#include <iostream>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <set>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define X first
#define Y second

using namespace std;

int x[2000000];
int y[2000000];
int n, m;
int fen[2000000];

void up(int v, int val){
	while (v <= n + 1){
		fen[v] += val;
		v = (v | (v + 1));
	}
}

int get(int v){
	int val = 0;
	while (v > 0){
		val += fen[v];
		v = (v & (v + 1)) - 1;
	}
	return val;
}

int u[2000000];

int a[2000000];
int b[2000000];
int q[2000000];

int main(){
	cin >> n >> m;
	int C = 0;
	for (int i = 1; i <= n; i++) up(i, 1);
	for (int i = 1; i <= m; i++){
		scanf("%d%d", &x[i], &y[i]);

		if (u[x[i]] == 1){
			continue;
		}
		u[x[i]] = 1;

		if (y[i]  <= C){
			cout << -1 << endl;
			return 0;
		}

		int lo = 0;
		int hi = n;
		while (lo + 1 < hi){
			int mid = (lo + hi) / 2;
			if (get(mid) >= y[i] - C) hi = mid; else lo = mid;
		}

		int p = hi;
		//cout << p << " " << y[i] - C <<  endl;

		a[p] = x[i];
		C++;

		up(p, -1);
	}

	int p = 0;
	u[p] = 1;
	for (int i = 1; i <= n; i++){
		if (a[i] == 0){
			while (u[p] == 1) p++;
			/*if (p > n){
				cout << -1 << endl;
				return 0;
			}*/
			a[i] = p;
			u[p] = 1;
		}
	}

	for (int i = 1; i <= n; i++){
		b[i] = a[i];
	}

	memset(u, 0, sizeof(u));
	memset(fen, 0, sizeof(fen));

	for (int i = 1; i <= m; i++){
		if (u[x[i]] == 0){
			up(1, 1);
			u[x[i]] = i;
			q[i] = get(i + 1);
			continue;
		}

		int p = get(u[x[i]] + 1) - q[u[x[i]]] + 1;
		q[i] = get(u[x[i]] + 1);
		up(u[x[i]] + 1, 1);

		if (p != y[i]){
			cout << -1 << endl;
			return 0;
		}

		u[x[i]] = i;
	}

	for (int i = 1; i <= n; i++){
		printf("%d", b[i]);
		if (i < n) printf(" "); else cout << endl;
	}

    //system("pause");
    return 0;
}

#include <cstdio>
#include <cstring>
#include <unordered_set>
#include <algorithm>

const int MAX_N = 1 << 21;

int n, m, bit[MAX_N + 1], pos[MAX_N + 1], ind[MAX_N + 1], ans[MAX_N + 1];
std::unordered_set<int> set;

void update(int p, int v)
{
	while (p <= MAX_N)
	{
		bit[p] += v;
		p += p & -p;
	}
}

int query(int p)
{
	int res = 0;
	while (p)
	{
		res += bit[p];
		p -= p & -p;
	}
	return res;
}

int find(int v)
{
	int res = 0;
	for (int step = MAX_N; step; step >>= 1)
		if (res + step <= MAX_N && bit[res + step] <= v)
			v -= bit[res += step];
	return res;
}

int main()
{
	memset(pos, 0xff, sizeof(pos));
	memset(ind, 0xff, sizeof(ind));
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) set.insert(i);
	for (int i = 0; i < n; ++i) update(MAX_N - i, 1);
	for (int i = 0; i < m; ++i)
	{
		int x, y; scanf("%d%d", &x, &y);
		int p = find(y);
		//printf("pos %d\n", p - MAX_N + n);
		if ((p <= MAX_N - n || !ans[p - MAX_N + n]) && (ind[p] == -1 || ind[p] == x))
		{
			if (p > MAX_N - n)
			{
				ans[p - MAX_N + n] = x;
				set.erase(x);
			}
			ind[MAX_N - n - i] = ind[p] = x;
			update(p + 1, -1); update(MAX_N - n - i, 1);
		}
		else { printf("-1\n"); return 0; }
	}
	for (int i = 1; i <= n; ++i)
		if (ans[i]) printf("%d ", ans[i]);
		else { printf("%d ", *set.begin()); set.erase(set.begin()); }
	printf("\n");
	return 0;
}

//tonynater - CodeForces 2014

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

using namespace std;

#define sz(x) ((int) x.size())

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;

const double pi = acos(-1);
const double tau = 2*pi;
const double epsilon = 1e-9;

const int MAX_N = 1000100;
const int MAX_M = 1000100;

int N, M;

int operations[MAX_M][2];

struct node
{
    int pr;

    int pos;
    int add;

    node *par;
    node *l;
    node *r;

    int mark;

    node()
    {
        pr = pos = mark = -1;
        par = l = r = NULL;
        add = 0;
    }
};

node treap[MAX_M]; int sz = 0;
node *rt = NULL;

void rLeft(node *p) //parent index
{
    if(p == NULL) return;
    else if(p->r == NULL) return;

    int add = p->add;
    if(add != 0)
    {
        p->pos += add;
        if(p->l != NULL) p->l->add += add;
        if(p->r != NULL) p->r->add += add;
        p->add = 0;
    }

    node *c = p->r;

    add = c->add;
    if(add != 0)
    {
        c->pos += add;
        if(c->l != NULL) c->l->add += add;
        if(c->r != NULL) c->r->add += add;
        c->add = 0;
    }

    c->par = p->par;
    if(c->par != NULL)
    {
        if(c->par->l == p) c->par->l = c;
        else c->par->l = c;
    }else rt = c;

    p->r = c->l;
    if(p->r != NULL) p->r->par = p;

    p->par = c;
    c->l = p;
}

void rRight(node *p)
{
    if(p == NULL) return;
    else if(p->l == NULL) return;

    int add = p->add;
    if(add != 0)
    {
        p->pos += add;
        if(p->l != NULL) p->l->add += add;
        if(p->r != NULL) p->r->add += add;
        p->add = 0;
    }

    node *c = p->l;

    add = c->add;
    if(add != 0)
    {
        c->pos += add;
        if(c->l != NULL) c->l->add += add;
        if(c->r != NULL) c->r->add += add;
        c->add = 0;
    }

    c->par = p->par;
    if(c->par != NULL)
    {
        if(c->par->l == p) c->par->l = c;
        else c->par->r = c;
    }else rt = c;

    p->l = c->r;
    if(p->l != NULL) p->l->par = p;

    p->par = c;
    c->r = p;
}

void insert(int pos, int mark)
{
    int pr = rand();

    node *cur = rt, *prv = NULL;
    while(cur != NULL)
    {
        int add = cur->add;
        if(add != 0)
        {
            cur->pos += add;
            if(cur->l != NULL) cur->l->add += add;
            if(cur->r != NULL) cur->r->add += add;
            cur->add = 0;
        }

        if(pos < cur->pos)
        {
            prv = cur;
            cur = cur->l;
        }else
        {
            prv = cur;
            cur = cur->r;
        }
    }

    treap[sz].pr = pr;
    treap[sz].pos = pos;
    treap[sz].mark = mark;
    treap[sz].par = prv;
    cur = &treap[sz++];

    if(cur->par == NULL) rt = cur;
    else
    {
        if(cur->pos < prv->pos) prv->l = cur;
        else prv->r = cur;
    }

    while(cur->par != NULL && cur->pr < cur->par->pr)
    {
        if(cur->par->l == cur) rRight(cur->par);
        else rLeft(cur->par);
    }
}

bool remove(int pos, int mark) //false - not found, true - found
{
    node *cur = rt, *prv = NULL;
    while(cur != NULL && cur->pos != pos)
    {
        int add = cur->add;
        if(add != 0)
        {
            cur->pos += add;
            if(cur->l != NULL) cur->l->add += add;
            if(cur->r != NULL) cur->r->add += add;
            cur->add = 0;
        }

        if(pos < cur->pos)
        {
            prv = cur;
            cur = cur->l;
        }else
        {
            prv = cur;
            cur = cur->r;
        }
    }

    if(cur == NULL) return false;
    else if(cur->mark != mark) return false;

    while(cur->l != NULL || cur->r != NULL)
    {
        if(cur->l == NULL) rLeft(cur);
        else if(cur->r == NULL) rRight(cur);
        else if(cur->l->pr < cur->r->pr) rRight(cur);
        else rLeft(cur);
    }

    if(cur == rt) rt = NULL;
    else if(cur->par->l == cur) cur->par->l = NULL;
    else cur->par->r = NULL;

    return true;
}

void decrement(node* cur, int bound)
{
    if(cur == NULL) return;
    else if(cur->pos <= bound)
    {
        if(cur->l != NULL) --cur->l->add;
        --cur->pos;
        decrement(cur->r, bound);
    }else decrement(cur->l, bound);
}

bool added[MAX_N];
bool isValid(int mark)
{
    node* cur = rt;
    while(cur != NULL && cur->pos != 0) cur = cur->l;

    if(cur == NULL) return !added[mark];
    else return (cur->mark == mark);
}

void impossible()
{
    cout << "-1\n";
    exit(0);
}

queue<pii> res;
void comp_res(node* cur)
{
    if(cur == NULL) return;

    int add = cur->add;
    if(add != 0)
    {
        cur->pos += add;
        if(cur->l != NULL) cur->l->add += add;
        if(cur->r != NULL) cur->r->add += add;
        cur->add = 0;
    }

    comp_res(cur->l);
    res.push(pii(cur->pos, cur->mark));
    comp_res(cur->r);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    srand(420);

    cin >> N >> M;

    for(int i = 0; i < M; i++)
        cin >> operations[i][0] >> operations[i][1];

    for(int i = M-1; i >= 0; i--)
    {
        int mark = operations[i][0], pos = operations[i][1];
        --pos; --mark;

        if(!isValid(mark)) impossible();

        if(added[mark]) remove(0, mark);
        decrement(rt, pos);
        insert(pos, mark);
        added[mark] = true;
    }

    comp_res(rt);

    for(int i = 0, idx = 0; i < N; i++)
    {
        if(!res.empty())
        {
            if(i == res.front().first)
            {
                cout << res.front().second+1 << ' ';
                res.pop();
            }else
            {
                while(added[idx]) ++idx;
                cout << idx+1 << ' ';
                ++idx;
            }
        }else
        {
            while(added[idx]) ++idx;
            cout << idx+1 << ' ';
            ++idx;
        }
    }
    cout << '\n';

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <ctime>
#define N 1000009
#define INF (-(1<<29))
using namespace std;
int n,m;
int pos[N],va[N];
class node{
public:
    int val;////position
    int fix;
    int sum;
    int mark;
    int pre;
    node *lson;
    node *rson;
    node(){
        rson=lson=NULL;
    }
    void ass(int v,int mk,int pr){
        val=v;
        mark=mk;
        sum=1;
        pre=pr;
        fix=rand();
    }
    bool operator < (struct node b)const{
        return val < b.val;
    }
};
class Treap{
public:
    node *Root;
    Treap(){
        Root=NULL;
    }
    void rotate_right(node* cur){
        node xx=*(cur->lson);
        cur->lson=xx.rson;
        xx.rson=new node();
        *(xx.rson)=*(cur);
        *cur=xx;
        update(cur->rson);
        update(cur);
    }
    void rotate_left(node* cur){
        node xx=*(cur->rson);
        cur->rson=xx.lson;
        xx.lson=new node();
        *(xx.lson)=*cur;
        *cur=xx;
        update(cur->lson);
        update(cur);
    }
    void update(node* cur){
        if(cur==NULL)return;
        int sum=1;
        if(cur->lson!=NULL)sum+=cur->lson->sum;
        if(cur->rson!=NULL)sum+=cur->rson->sum;
        cur->sum=sum;
    }
    void insert(node* root,node ad){
        if(Root==NULL){
            Root=new node();
            *Root=ad;
        }else if(ad.val < root->val){
            root->sum++;
            if(root->lson==NULL){
                root->lson=new node();
                *(root->lson)=ad;
            }else{
                insert(root->lson,ad);
            }
            if(root->lson->fix < root->fix)
                rotate_right(root);
        }else{
            root->sum++;
            if(root->rson==NULL){
                root->rson=new node();
                *(root->rson)=ad;
            }else{
                insert(root->rson,ad);
            }
            if(root->rson->fix < root->fix)
                rotate_left(root);
        }
    }
    void pt(node* root){
        if(root==NULL)return;
        pt(root->lson);
        pos[root->pre]=root->mark;
        pt(root->rson);
    }
    node findkth(node* root,int k){
        int lsum=0;
        if(root->lson!=NULL) lsum=root->lson->sum;
        if(k<=lsum){
            return findkth(root->lson,k);
        }else if(k==lsum+1){
            return *root;
        }else{
            return findkth(root->rson,k-lsum-1);
        }
    }
    node* del(node* root,int val){
        if(root==NULL)return root;
        else if(root->val > val){
            root->lson=del(root->lson,val);
        }else if(root->val < val){
            root->rson=del(root->rson,val);
        }else{
            if(root->lson==NULL && root->rson==NULL){
                if(root==Root)Root=NULL;
                root=NULL;
            }else if(root->lson==NULL){
                *(root)=*(root->rson);
            }else if(root->rson==NULL){
                *(root)=*(root->lson);
            }else{
                if(root->lson->fix < root->rson->fix){
                    rotate_right(root);
                    root->rson=del(root->rson,val);
                }else{
                    rotate_left(root);
                    root->lson=del(root->lson,val);
                }
            }
        }
        update(root);
        return root;
    }
};
int main()
{
    //freopen("in.txt","r",stdin);
    srand(time(0));
    Treap treap;
    cin>>n>>m;
    int head=1;
    bool flag=true;
    node cur;
    for(int i=1;i<=n;i++){
        cur.ass(i,-1,i);
        va[i]=INF;
        treap.insert(treap.Root,cur);
    }
    for(int i=0,x,y;i<m;i++){
        cin>>x>>y;
        cur=treap.findkth(treap.Root,y);
        if(!flag)continue;
        if(cur.mark==-1 || cur.mark==x){
            if(va[x]!=INF && va[x]!=cur.val){
                flag=false;continue;
            }
            treap.del(treap.Root,cur.val);
            cur.lson=cur.rson=NULL;
            cur.val=--head;
            cur.mark=x;
            va[x]=cur.val;
            treap.insert(treap.Root,cur);
        }else flag=false;
    }
    if(!flag){
        cout<<"-1"<<endl;
    }else{
        treap.pt(treap.Root);
        set<int> s;
        for(int i=1;i<=n;i++)s.insert(i);
        for(int i=1;i<=n;i++)if(pos[i]!=-1)s.erase(pos[i]);
        for(int i=1;i<=n;i++)if(pos[i]==-1){
            pos[i]=*(s.begin());
            s.erase(s.begin());
        }
        for(int i=1;i<=n;i++){
            printf("%d%c",pos[i],(i==n?'\n':' '));
        }
    }
    return 0;
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;

#define TRACE(x...) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define PRINT(x...) TRACE(printf(x))

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define FU(i, a, b) for(decltype(a) i = (a); i < (b); ++i)
#define fu(i, n) FU(i, 0, n)

#define mset(c, v) memset(c, v, sizeof(c))
#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define SZ(c) int((c).size())

const int INF = 0x3F3F3F3F; const int NEGINF = 0xC0C0C0C0;
const double EPS = 1e-8;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef long long ll;

class BIT {
	private:
		vector<int> tree;
		int N;
	public:
		BIT(int _N){
			N = _N+1;
			tree.resize(N,0);
		}

		void update(int ind, int value){
			ind++;
			while(ind<N)
			{
				tree[ind] += value;
				ind += (ind & -ind);
			}
		}

		int get(int ind){
			int sum=0;
			while(ind > 0)
			{
				sum += tree[ind];
				ind -= (ind & -ind);
			}
			return sum;
		}

		int get(int ind1, int ind2)	{
			if (ind1>=ind2) return 0;
			return get(ind2) - get(ind1);
		}
};

int cmp(double x, double y = 0, double tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
char ans[10000000];
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	BIT bit(n+1);
	vi pos(n, -1), last(n, -1), used(n, -1);
	bool valid = true;
	int k = 0;
	fu(i, m) {
		int x, y;
		scanf("%d %d", &x, &y); x--; y--;
		if (pos[x] == -1) {
			if (y < k) {
				valid = false;
				break;
			}
			pos[x] = -1;
			int mi = 0;
			int ma = n;
			while (ma > mi) {
				int me = (ma + mi)/2;
				int z = me + k - bit.get(me);
				if (used[me] == -1 && z == y) {
					used[me] = x;
					pos[x] = me;
					bit.update(me, +1);
					break;
				} else if (z <= y) mi = me + 1;
				else ma = me;
			}
			if (pos[x] == -1) {
				valid = false;
				break;
			}
			k++;
		} else {
			if (y >= k) {
				valid = false;
				break;
			}
			if (y != i - last[x] - 1) {
				valid = false;
				break;
			}
		}
		last[x] = i;
	}
	if (!valid) printf("-1\n");
	else {
		int cur = 0;
		int posi = 0;
		fu(i, n) {
			if (i) ans[posi++] = ' ';
			if (used[i] != -1) posi += sprintf(ans + posi, "%d", used[i]+1);
			else {
				while (pos[cur] != -1) cur++;
				posi += sprintf(ans + posi, "%d", cur+1);
				cur++;
			}
		}
		ans[posi] = '\0';
		printf("%s\n", ans);
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <map>
#include <cstring>
using namespace std;

int n, m;

int res[1000007];
bool used[1000007];

typedef struct item * pitem;

struct item
{
    int prior, value, cnt;
    pitem l, r;
};
int cnt (pitem it)
{
    return it ? it->cnt : 0;
}
void upd_cnt (pitem it)
{
    if (it)
        it->cnt = cnt(it->l) + cnt(it->r) + 1;
}
void merge (pitem & t, pitem l, pitem r)
{
    if (!l || !r)
        t = l ? l : r;
    else if (l->prior > r->prior)
        merge (l->r, l->r, r),  t = l;
    else
        merge (r->l, l, r->l),  t = r;
    upd_cnt (t);
}
void split (pitem t, pitem & l, pitem & r, int key, int add = 0)
{
    if (!t)
        return void( l = r = 0 );
    int cur_key = add + cnt(t->l);
    if (key <= cur_key)
        split (t->l, l, t->l, key, add),  r = t;
    else
        split (t->r, t->r, r, key, add + 1 + cnt(t->l)),  l = t;
    upd_cnt (t);
}
int spusk(pitem t)
{
   if (t->r != NULL)
       return spusk(t->r);
   else
       return t->value;
}

pitem ver;

struct node
{
   node *l, *r;
   int v;
};
node *root = new node();
void build(node *ver, int l, int r)
{
    if (l == r)
    {
        ver->v = 0;
        ver->l = NULL;
        ver->r = NULL;
    }
    else
    {
        ver->l = new node();
        ver->r = new node();
        build(ver->l, l, (l + r) / 2);
        build(ver->r, (l + r) / 2 + 1, r);
        ver->v = ver->l->v  + ver->r->v;
    }
}
int up (node *ver, int l, int r, int p, int v)
{
    if (l == r)
        ver->v += v;
    else
    {
        ver->v += v;
        int m = (l + r) / 2;
        if (p > m)
            up(ver->r, m + 1, r, p, v);
        else
            up(ver->l, l, m, p, v);
    }
}
int get(node *ver, int l, int r, int b)
{
    if (l == r)
    {
        if (l == b && ver->v == 0)
            return l;
        else
            return -1;
    }
    else
    {
        if ((l + r) / 2 + 1 + ver->r->v <= b)
        {
            return get (ver->r, (l + r) / 2 + 1, r, b);
        }
        else
        {
            return get(ver->l, l, (l + r ) / 2, b - ver->r->v);
        }
    }
}

int main()
{
    srand(10503);

    cin >> n >> m;

    build (root, 1, n);

    memset(res, 0, sizeof(int) * 1000007);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);

        int p = get(root, 1, n, b);

        if (!used[a])
        {
            if (p == -1)
            {
                cout << -1;
                return 0;
            }
            res[p] = a;

            used[a] = true;
            up(root, 1, n, p, 1);

            pitem ne = new item();
            ne->value = a;
            ne->prior = rand() % (1000 * n);
            ne->cnt = 1;
            merge(ver, ver, ne);
        }
        else
        {
            pitem l, r;
            split(ver, l, r, b);
            if (spusk(l) != a)
            {
                cout << -1;
                return 0;
            }
            merge(ver, l, r);
        }
    }

    int i = 1, j = 1;
    while (i <= n)
    {
        while (j <= n && used[j]) j++;
        while (i <= n && res[i] != 0) i++;
        res[i] = j;
        i++;
        j++;
    }

    for (int i = 1; i <= n; i++)
    {
        printf("%d ", res[i]);
    }
    return 0;
}

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define TRACE(x) cout << #x << " = " << x << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef pair<int, int> par;
#define a first
#define b second

const int MAXN = 2000010;

struct node {
  par x;
  int pri, size;
  node *l, *r;
  inline void update() { size = l->size + 1 + r->size; }
} mem[MAXN];

node *root, *null, *alloc;

node *rotate( node *x, node *y ) {
  if( y == x->l ) { x->l = y->r; y->r = x; } else
    if( y == x->r ) { x->r = y->l; y->l = x; }
  x->update(), y->update();
  return y;
}

node *newnode( par x ) {
  node *p = alloc++;
  p->x = x, p->pri = rand();
  p->l = p->r = null, p->size = 1;
  return p;
}

node *insert( node *x, par z ) {
  if( x == null ) return newnode( z );
  if( x->x == z ) return x;
  if( z < x->x ) {
    x->l = insert( x->l, z );
    if( x->l->pri > x->pri ) x = rotate( x, x->l );
  } else {
    x->r = insert( x->r, z );
    if( x->r->pri > x->pri ) x = rotate( x, x->r );
  }
  x->update();
  return x;
}

node *erase( node *x, par z ) {
  if( x == null ) return x;
  if( z < x->x ) x->l = erase( x->l, z );
  if( z > x->x ) x->r = erase( x->r, z );
  if( z == x->x ) {
    if( x->l == null && x->r == null ) return null;
    if( x->l->pri > x->r->pri ) x =  rotate( x, x->l ); else
      x = rotate( x, x->r );
    x = erase( x, z );
  }
  x->update();
  return x;
}

par kth( node *x, int k ) {
  if( k <= x->l->size ) return kth( x->l, k );
  if( k == x->l->size+1 ) return x->x;
  return kth( x->r, k - x->l->size - 1 );
}

void init() {
  srand(43974231);
  alloc = mem;
  null = alloc++;
  null->pri = 1, null->size = 0;
  null->l = null->r = null;
  root = null;
};

void insert( par x ) { root = insert( root, x ); }
void erase( par x ) { root = erase( root, x ); }
par kth( int x ) { return kth( root, x ); }
int size() { return root->size; }

int f[MAXN];
int g[MAXN];

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  init();
  REP(i, n) {
    f[i] = g[i] = -1;
    insert({i, i});
  }

  par p;
  int x, y;
  REP(i, m) {
    scanf("%d %d", &x, &y); --x, --y;
    // uzmi y-tog - on je jednak x, i ubaci na ga prvo mjesto
    p = kth(y+1);
    if (f[p.b] == -1) f[p.b] = x;
    if (g[x] == -1) g[x] = p.b;
    if (f[p.b] != x || g[x] != p.b) { puts("-1"); return 0; }

    erase(p);
    p.a = -i-1;
    insert(p);
  }

  int ptr = 0;
  REP(i, n)
    if (g[i] == -1) {
      while (ptr < n && f[ptr] != -1) ptr++;
      f[ptr] = i;
    }

  REP(i, n)
    printf("%d%c", f[i]+1, i+1 < n ? ' ' : '\n');

  return 0;
}

/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 2000010;
const ll maxnlg = 22;

ll n, m;
ll X[maxn], Y[maxn];
ll fen[maxn];
ll pos[maxn], now[maxn], vis[maxn];
ll res[maxn];

void update(ll i, ll v) {
    for (++i; i < maxn; i += i & -i) fen[i] += v;
}

ll get(ll i) {
    ll s = 0;
    for (++i; i; i ^= i & -i) s += fen[i];
    return s;
}

ll search(ll v) {
    ll i = 0;
    ll t = get(maxn - 2);
    ll a = 0;
    forir (b, maxnlg) {
        if (i + (1 << b) < maxn && i + (1 << b) + a + t - fen[i ^ (1 << b)] < v) {
            i ^= 1 << b;
            a += fen[i];
        }
    }
    return i;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> m;
    fori (i, m) cin >> X[i] >> Y[i], --X[i], --Y[i];
    memset(pos, -1, sizeof pos);
    fori (i, m) {
        if (pos[X[i]] == -1) {
            ll p = search(Y[i] + 1);
            if (vis[p] || p + get(maxn - 2) - get(p) != Y[i]) {
                cout << "-1\n";
                return 0;
            }
            update(p, 1);
            pos[X[i]] = p;
            vis[p] = 1;
        }
    }

    ll p = 0;
    fori (i, n) {
        if (pos[i] == -1) {
            while (vis[p]) ++p;
            pos[i] = p; vis[p] = 1;
        }
    }

    fori (i, n) res[pos[i]] = i + 1;

    fori (i, n) pos[i] += n;
    memset(fen, 0, sizeof fen);
    fori (i, n) update(i + n, 1);
    fori (i, m) {
        if (get(pos[X[i]] - 1) != Y[i]) {
            cout << "-1\n";
            return 0;
        }
        update(pos[X[i]], -1);
        pos[X[i]] = n - 1 - i;
        update(n - 1 - i, 1);
    }

    fori (i, n) cout << res[i] << ' ';
    cout << '\n';

}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;

template <class T>
class myset {
    public:

    myset()
    {
        top = NULL;
    }

    ~myset()
    {
        clear(top);
    }

    bool empty(void)
    {
        return top == NULL;
    }

    int size(void)
    {
        return size(top);
    }

    void insert(T key)
    {
        top = insert(top, key);
    }

    void erase(T key)
    {
        top = erase(top, key);
    }

    int find(T key)
    {
        int tmp = find(top, key);

        return tmp == -1 ? size(top) : tmp;
    }

    int count(T key)
    {
        return find(top, key) == -1 ? 0 : 1;
    }

    void clear(void)
    {
        clear(top);
        top = NULL;
    }

    T rank(int n)
    {
        return rank(top, n);
    }

    int lower_bound(T key)
    {
        return lower_bound(top, key);
    }

    int upper_bound(T key)
    {
        return upper_bound(top, key);
    }

    private:

    typedef struct _myset {
        T key;
        int size;
        int height;
        struct _myset *child[2];
    } _myset;

    _myset *top;

    int size(_myset *s)
    {
        return s == NULL ? 0 : s->size;
    }

    int height(_myset *s)
    {
        return s == NULL ? 0 : s->height;
    }

    _myset *balance(_myset *s)
    {
        for (int i = 0; i < 2; i++) {
            if (height(s->child[!i]) - height(s->child[i]) < -1) {
                if (height(s->child[i]->child[!i]) - height(s->child[i]->child[i]) > 0) {
                    s->child[i] = rotate(s->child[i], i, !i);
                }

                return rotate(s, !i, i);
            }
        }

        if (s != NULL) {
            s->height = max(height(s->child[0]), height(s->child[1])) + 1;
            s->size = size(s->child[0]) + size(s->child[1]) + 1;
        }

        return s;
    }

    _myset *rotate(_myset *s, int l, int r)
    {
        _myset *t = s->child[r];

        s->child[r] = t->child[l];
        t->child[l] = balance(s);

        if (s != NULL) s->size = size(s->child[0]) + size(s->child[1]) + 1;
        if (t != NULL) t->size = size(t->child[0]) + size(t->child[1]) + 1;

        return balance(t);
    }

    _myset *insert(_myset *s, T key)
    {
        if (s == NULL) {
            _myset *tmp = new _myset;

            tmp->key = key;
            tmp->size = 1;
            tmp->height = 1;
            tmp->child[0] = NULL;
            tmp->child[1] = NULL;

            return tmp;
        }

        if (key < s->key) {
            s->child[0] = insert(s->child[0], key);
        } else if (key == s->key) {
            return s;
        } else {
            s->child[1] = insert(s->child[1], key);
        }

        s->size++;

        return balance(s);
    }

    _myset *move_down(_myset *s, _myset *t)
    {
        if (s == NULL) return t;

        s->child[1] = move_down(s->child[1], t);

        return balance(s);
    }

    _myset *erase(_myset *s, T key)
    {
        if (s == NULL) return NULL;

        if (key < s->key) {
            s->child[0] = erase(s->child[0], key);
        } else if (key == s->key) {
            _myset *tmp = move_down(s->child[0], s->child[1]);

            delete s;

            return tmp;
        } else {
            s->child[1] = erase(s->child[1], key);
        }

        s->size--;

        return balance(s);
    }

    int find(_myset *s, T key)
    {
        if (s == NULL) return -1;

        if (key < s->key) {
            return find(s->child[0], key);
        } else if (key == s->key) {
            return size(s->child[0]);
        } else {
            int tmp = find(s->child[1], key);

            if (tmp >= 0) tmp += size(s->child[0]) + 1;

            return tmp;
        }
    }

    void clear(_myset *s)
    {
        if (s == NULL) return;

        if (s->child[0] != NULL) clear(s->child[0]);
        if (s->child[1] != NULL) clear(s->child[1]);

        delete s;
    }

    T rank(_myset *s, int n)
    {
        int m = size(s->child[0]);

        if (n < m) {
            return rank(s->child[0], n);
        } else if (n == m) {
            return s->key;
        } else {
            return rank(s->child[1], n - m - 1);
        }
    }

    int lower_bound(_myset *s, T key)
    {
        if (s == NULL) return 0;

        if (key <= s->key) {
            return lower_bound(s->child[0], key);
        } else {
            return size(s->child[0]) + 1 + lower_bound(s->child[1], key);
        }
    }

    int upper_bound(_myset *s, T key)
    {
        if (s == NULL) return 0;

        if (key < s->key) {
            return upper_bound(s->child[0], key);
        } else {
            return size(s->child[0]) + 1 + upper_bound(s->child[1], key);
        }
    }
};

int a[1000000];
int b[1000000];

int main()
{
    int n, m, sum = 0, i, j;
    myset <int> s;
    rope <int> r;

    scanf("%d %d", &n, &m);

    for (i = 0; i < n; i++) a[i] = -1;

    for (i = 0; i < n; i++) s.insert(i);

    for (i = 0; i < m; i++) {
        int x, y, z;

        scanf("%d %d", &x, &y);

        x--;
        y--;

        if (a[x] == -1) {
            if (sum > y) {
                puts("-1");

                return 0;
            }

            z = s.rank(y - sum);

            s.erase(z);

            sum++;

            b[z] = x + 1;
        } else {
            if (y > i - a[x] - 1) {
                puts("-1");

                return 0;
            }

            if (r[y] != x) {
                puts("-1");

                return 0;
            }

            r.erase(y);
        }

        a[x] = i;
        r.push_front(x);
    }

    for (i = 0, j = 0; i < n; i++) {
        if (a[i] == -1) {
            for (; j < n; j++) {
                if (b[j] == 0) {
                    b[j] = i + 1;

                    break;
                }
            }
        }
    }

    for (i = 0; i < n; i++) {
        if (i > 0) putchar(' ');

        printf("%d", b[i]);
    }

    puts("");

    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#define LL long long
#define lc (p<<1)
#define rc ((p<<1)+1)
using namespace std;
int n,m,where[1000010],ans[1000010],x,y,pre[1000010];
struct node
{
	int Min,sum;
}tr[4000010];
struct segtree
{
	struct node1
	{
		int flag,sum;
	}tr[4000010];
	void pushdown(int p)
	{
		tr[lc].flag+=tr[p].flag;
		tr[lc].sum+=tr[p].flag;
		tr[rc].flag+=tr[p].flag;
		tr[rc].sum+=tr[p].flag;
		tr[p].flag=0;
	}
	void Insert(int p,int l,int r,int a,int b)
	{
		if (l==a&&r==b)
		{
			tr[p].flag++,tr[p].sum++;return;
		}
		if (tr[p].flag) pushdown(p);
		int mid=(l+r)>>1;
		if (b<=mid) Insert(lc,l,mid,a,b);
		else if (a>=mid) Insert(rc,mid,r,a,b);
		else
		{
			Insert(lc,l,mid,a,mid);Insert(rc,mid,r,mid,b);
		}
	}
	int Get(int p,int l,int r,int x)
	{
		if (l==r-1) return tr[p].sum;
		if (tr[p].flag) pushdown(p);
		int mid=(l+r)>>1;
		if (x+1<=mid) return Get(lc,l,mid,x);return Get(rc,mid,r,x);
	}
}C;
bool vis[1000010];
void read(int &x)
{
	char ch=getchar();int mark=1;for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());if (ch=='-') mark=-1,ch=getchar();
	for(x=0;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-48;x*=mark;
}
void updata(int p)
{
	tr[p].sum=tr[lc].sum+tr[rc].sum;
	tr[p].Min=min(tr[lc].Min,tr[rc].Min);
}
void Build(int p,int l,int r)
{
	if (l==r-1)
	{
		tr[p].sum=0;
		tr[p].Min=n+1;
		return;
	}
	int mid=(l+r)>>1;
	Build(lc,l,mid);Build(rc,mid,r);
	updata(p);
}
int Getpos(int p,int l,int r,int B)
{
	if (l==r-1) return l;
	int mid=(l+r)>>1;
	if (tr[rc].Min==n+1)
	{
		if (mid<=B) return B;
		else return Getpos(lc,l,mid,B);
	}
	if (tr[rc].Min+tr[rc].sum<=B) return Getpos(rc,mid,r,B);
	return Getpos(lc,l,mid,B-tr[rc].sum);
}
int Getsum(int p,int l,int r,int a,int b)
{
	if (l==a&&r==b) return tr[p].sum;
	int mid=(l+r)>>1;
	if (b<=mid) return Getsum(lc,l,mid,a,b);
	if (a>=mid) return Getsum(rc,mid,r,a,b);
	return Getsum(lc,l,mid,a,mid)+Getsum(rc,mid,r,mid,b);
}
void Insert(int p,int l,int r,int x)
{
	if (l==r-1)
	{
		tr[p].Min=l;tr[p].sum=1;return;
	}
	int mid=(l+r)>>1;
	if (x+1<=mid) Insert(lc,l,mid,x);
	else Insert(rc,mid,r,x);
}
int main()
{
	read(n);read(m);
	bool flag=1;
	Build(1,1,n+1);
	for(int i=1;i<=m;i++)
	{
		read(x);read(y);
		if (!where[x])
		{
			int t=Getpos(1,1,n+1,y);
			pre[x]=i;
			if (!vis[t]&&Getsum(1,1,n+1,t,n+1)+t==y)
			{
				Insert(1,1,n+1,x);
				where[x]=t;
			}
			else
			{
				flag=0;break;
			}
		}
		else
		{
			int t=pre[x]+1;
			C.Insert(1,1,m+1,t,i+1);
			if (C.Get(1,1,m+1,pre[x])==y-1);
			else
			{
				flag=0;break;
			}
			pre[x]=i;
		}
	}
	if (flag)
	{
		for(int i=1;i<=n;i++)
			if (where[i]) ans[where[i]]=i;
		int now=0;
		for(int i=1;i<=n;i++)
			if (ans[i]) printf("%d ",ans[i]);
			else
			{
				now++;
				for(;where[now];now++);
				printf("%d ",now);
			}
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

struct splay_tree {
	static const int maxNode = 1e6 + 100;
#define splay_node sn
#define lc ch[0]
#define rc ch[1]
	typedef long long LL;
	struct splay_node {
		splay_node*fa, *ch[2];
		int p;
		int d() {
			return fa->ch[0] == this;
		}
		int sz;

		splay_node() {
			fa = ch[0] = ch[1] = NULL;
		}

		void init(int pos) {
			fa = ch[0] = ch[1] = NULL;
			p = pos;
		}

		void update() {
			sz = (ch[0] ? ch[0]->sz : 0) + (ch[1] ? ch[1]->sz : 0) + 1;
		}

	} node_pool[maxNode], *loc = node_pool;

	splay_node *root, *lmost, *rmost;

	void init() {
		lmost = loc++;
		rmost = loc++;
		lmost->p = INT_MIN;
		rmost->p = INT_MAX;
		lmost->ch[1] = rmost;
		rmost->fa = lmost;
		root = lmost;
		rmost->update();
		lmost->update();
	}

	void rot(splay_node*x) {
		splay_node*y = x->fa, *z = y->fa;
		int d = x->d();
		y->ch[d^1] = x->ch[d];
		if (x->ch[d]) x->ch[d]->fa = y;
		x->ch[d] = y;
		y->fa = x;
		x->fa = z;
		if (z) z->ch[z->ch[1]==y] = x;
		y->update();
	}

	void splay(splay_node*x, splay_node*g) {
		for (; x->fa != g; rot(x)) {
			splay_node*y = x->fa;
			if (y->fa != g) {
				if (x->d() == y->d())
					rot(y);
				else rot(x);
			}
		}
		x->update();
		if (!g) root = x;
	}

	void insert(splay_node*&pos, splay_node*nd) {
		if (!pos) {
			pos = nd;
			nd->update();
			return ;
		}
		if (nd->p < pos->p) {
			insert(pos->ch[0], nd);
			pos->ch[0]->fa = pos;
		}
		else {
			insert(pos->ch[1], nd);
			pos->ch[1]->fa = pos;
		}
		pos->update();
	}

	void insert(int p) {
		splay_node *new_node = loc++;
		new_node->init(p);
		insert(root, new_node);
		splay(new_node, NULL);
	}

	splay_node*get_prev(splay_node*pos, int p) {
		if (!pos) return NULL;
		if (p <= pos->p) {
			return get_prev(pos->ch[0], p);
		} else {
			splay_node*temp = get_prev(pos->ch[1], p);
			if (!temp || p <= temp->p)
				return pos;
			else return temp;
		}
	}
	splay_node*get_succ(splay_node*pos, int p) {
		if (!pos) return NULL;
		if (pos->p <= p) {
			return get_succ(pos->ch[1], p);
		} else {
			splay_node*temp = get_succ(pos->ch[0], p);
			if (!temp || temp->p <= p)
				return pos;
			else return temp;
		}
	}

	splay_node*get_by_rnk(splay_node*x, int k) {
		if (k > x->sz) return NULL;
		if (x->ch[0]) {
			if (x->ch[0]->sz < k)
				k -= x->ch[0]->sz;
			else return get_by_rnk(x->ch[0], k);
		}
		if (k == 1) return x;
		return get_by_rnk(x->ch[1], k-1);
	}

	splay_node*get_prev(int p) {
		return get_prev(root, p);
	}
	splay_node*get_succ(int p) {
		return get_succ(root, p);
	}
	splay_node*get_by_rnk(int k) {
		return get_by_rnk(root, k+1);
	}

	void del_node(splay_node*x) {
		splay(x, NULL);
		int s = x->ch[0] ? x->ch[0]->sz : 1;
		splay_node*l = get_by_rnk(s-1), *r = get_by_rnk(s+1);
		splay(l, NULL);
		splay(r, l);
		r->ch[0] = NULL;
		x->fa = NULL;
		r->update();
		l->update();
	}
};

int main() {
#ifdef love_lwd
	freopen("420D.in", "r", stdin);
	freopen("420D.out", "w", stdout);
#endif
	static int n, m, p, v, val[splay_tree::maxNode];
	static set<int> has;
	scanf("%d%d", &n, &m);
	splay_tree *st = new splay_tree();
	st->init();
	for (int i = 1; i <= n; ++i) {
		st->insert(i);
	}
	memset(val, -1, sizeof val);
	while (m--) {
		scanf("%d%d", &v, &p);
		splay_tree::splay_node *t = st->get_by_rnk(p), *a, *b;
		st->del_node(t);
		a = st->get_by_rnk(0);
		b = st->get_by_rnk(1);
		st->splay(a, NULL);
		st->splay(b, a);
		b->ch[0] = t;
		t->fa = b;
		b->update();
		a->update();
		if (val[t->p] == -1)
			val[t->p] = v;
		else if (val[t->p] != v) {
			puts("-1");
			return 0;
		}
	}
	for (int i = 1; i <= n; ++i)
		if (val[i] != -1)
			has.insert(val[i]);
	p = 1;
	//for (int i = 1; i <= n; ++i)
	//	printf("%d ", val[i]);
	//puts("");
	for (int i = 1; i <= n; ++i) {
		if (val[i] == -1) {
			while (has.find(p) != has.end())
				++p;
			val[i] = p;
			has.insert(p);
		}
	}
	if (p != n) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= n; ++i)
		printf("%d ", val[i]);
	puts("");

	return 0;
}

//Template
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
	static int r, sign;
	static char c;
	r = 0, sign = 1;
	do c = getchar(); while (c != '-' && (c < '0' || c > '9'));
	if (c == '-') sign = -1, c = getchar();
	while (c >= '0' && c <= '9') r = r * 10 + (int)(c - '0'), c = getchar();
	return sign * r;
}

template <typename T>
inline void print(T *a, int n) {
	for (int i = 1; i < n; ++i) cout << a[i] << " ";
	cout << a[n] << endl;
}
#define PRINT(_l, _r, _s, _t) { cout << #_l #_s "~" #_t #_r ": "; for (int _i = _s; _i != _t; ++_i) cout << _l _i _r << " "; cout << endl; }

#define N 1000000

struct oper {
	int l, r, n, ans;
} q[N + 1];

inline bool cmp1(const oper &x, const oper &y) {
	return x.l < y.l;
}

inline bool cmp2(const oper &x, const oper &y) {
	return x.n < y.n;
}

int n, m, x[N + 1], y[N + 1], p[N + 1], pos[N + 1], seq[N + 1];

struct BIT {
	int arr[N + 1], n;

	inline void modify(int x, int v) {
		for (; x <= n; x += x & -x) arr[x] += v;
	}

	inline int query(int x) {
		int r = 0;
		for (; x > 0; x -= x & -x) r += arr[x];
		return r;
	}
} T;

int tree[N * 5];

inline void update(int x) {
	tree[x] = tree[x << 1] + tree[x << 1 | 1];
}

void build(int x, int l, int r) {
	if (l == r) {
		tree[x] = 1;
		return ;
	}
	int mid = l + r >> 1;
	build(x << 1, l, mid);
	build(x << 1 | 1, mid + 1, r);
	update(x);
}

void modify(int x, int l, int r, int p) {
	if (l == r) {
		tree[x] = 0;
		return ;
	}
	int mid = l + r >> 1;
	if (p <= mid) modify(x << 1, l, mid, p);
	else modify(x << 1 | 1, mid + 1, r, p);
	update(x);
}

int query(int x, int l, int r, int k) {
	if (l == r) return l;
	int mid = l + r >> 1;
	if (tree[x << 1] >= k) return query(x << 1, l, mid, k);
	else return query(x << 1 | 1, mid + 1, r, k - tree[x << 1]);
}

int main(int argc, char *argv[]) {
#ifdef KANARI
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i)
		scanf("%d%d", x + i, y + i);
	for (int i = 1; i <= m; ++i) {
		p[i] = pos[x[i]];
		pos[x[i]] = i;
		q[i].l = p[i] + 1, q[i].r = i, q[i].n = i;
	}

	sort(q + 1, q + m + 1, cmp1);
	T.n = m;
	for (int i = 1, j = 1; i <= m; ++i) {
		if (p[i] > 0) T.modify(p[i], -1);
		T.modify(i, 1);
		while (j <= m && q[j].l == i) {
			q[j].ans = T.query(q[j].r);
			++j;
		}
	}

	build(1, 1, n);
	sort(q + 1, q + m + 1, cmp2);
//	P.n = n;
//	for (int i = 1; i <= n; ++i) P.modify(i, 1);
	for (int i = 1; i <= n; ++i) pos[i] = 0;
	bool ok = true;
	for (int i = 1; i <= m; ++i) {
		if (pos[x[i]] != 0 && y[i] != q[i].ans) ok = false;
		if (pos[x[i]] == 0) {
			if (y[i] >= i) {
				pos[x[i]] = query(1, 1, n, y[i] - i + 1);
				modify(1, 1, n, pos[x[i]]);
			} else printf("WTF? %d\n", i);
		}
//		if (y[i] >= i) modify(1, 1, n, query(1, 1, n, y[i] - i + 1));
//		for (int j = 1; j <= n; ++j) printf("%d ", P.query(j));
//		printf("\n");
	}
	if (!ok) printf("-1\n");
	else {
//		print(pos, n);
		for (int i = 1; i <= n; ++i)
			if (pos[i] != 0) seq[pos[i]] = i;
		for (int i = 1, j = 1; i <= n; ++i)
			if (seq[i] == 0) {
				while (j <= n && pos[j] != 0) ++j;
				seq[i] = j++;
			}
		for (int i = 1; i < n; ++i) printf("%d ", seq[i]);
		printf("%d\n", seq[n]);
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <cstring>
const int N = 4e6 + 100;
int n, m;

int val[N], used[N], ans[N];

struct fenwick {
	int n, c[N];
	fenwick(int _n = N - 1):n(_n) {
		memset(c, 0, sizeof c);
	}
	void insert(int p) {
		if (p < 0) return ;
		for (; p <= n; ++c[p], p += p & -p);
	}
	int find_by_order(int k) {
		++k;
		int x = 0;
		for (int i = 21; 0 <= i; --i)
			if (x + (1 << i) <= n && c[x + (1 << i)] < k)
				x += 1 << i, k -= c[x];
		return x + 1;
	}
	void erase(int p) {
		for (; p <= n; --c[p], p += p & -p);
	}
} pos;

int main() {

#ifdef lol
	freopen("420D.in", "r", stdin);
#endif

	scanf("%d%d", &n, &m);
	for (int i = m + 1; i <= n + m; ++i)
		pos.insert(i);
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		auto p = pos.find_by_order(y);
		int t = p;
		pos.erase(p);
		if (!val[t]) {
			ans[t - m] = x;
			if (used[x]) return puts("-1"), 0;
			used[x] = true;
			val[m - i + 1] = x;
			t = m - i + 1;
		} else {
			if (val[t] != x) return puts("-1"), 0;
			val[m - i + 1] = val[t];
			t = m - i + 1;
		}
		pos.insert(t);
	}
	int t = 1;
	for (int i = 1; i <= n; ++i)
		if (!ans[i]) {
			while (used[t]) ++t;
			ans[i] = t++;
		}
	for (int i = 1; i <= n; ++i)
		printf("%d ", ans[i]);
	puts("");

	return 0;
}

#include <iostream>
#include<cstring>
#include<set>
#define SIZE 2100000
#define UNKNOWN -1e9
using namespace std;
// value stored from [1,n]
int mark[SIZE];
int prev[SIZE];
int tree[SIZE];
void update(int idx,int val,int n)
{
    while(idx <= n)
    {
        tree[idx]+=val;
        idx += (idx & -idx); // add the last non-zero digit
    }
}
int read(int idx)
{
    int sum = 0;
    while(idx > 0)
    {
        sum+=tree[idx];
        idx -= (idx & -idx); // deduct the last non-zero digit
    }
    return sum;
}
int msearch(int p,int sz)
{
    int low = 1,high = sz;
    while(low<=high)
    {
        int mid = (low+high)/2;
        int v = read(mid);
        if(v < p)low = mid+1;
        else if(v > p)high = mid-1;
        else return mid;
    }
    return -1;
}
int main()
{
    // given a list of number from A[1,n]
    // change a value in A[i]
    // query the sum in range A[1,j]
    int n,q,off;
    set<int> s;
    cin>>n>>q;
    off = n;
    for(int i=1;i<=2*n;i++) mark[i] = prev[i] = UNKNOWN;
    for(int i=1;i<=n;i++)
    {
        s.insert(i);
        update(off+i,1,2*n);
    }
    bool yes = true;
    for(int i=0;yes && i<q;i++)
    {
        int m,p;
        cin>>m>>p;
        int t = msearch(p,2*n);
        if(t==-1)cout<<"search error"<<endl;
        if(mark[t] == UNKNOWN)
        {
            if(s.find(m)==s.end())
            {
                yes = false;
                continue;
            }
            s.erase(m);
            mark[t] = m;
        }
        if(mark[t] != m)yes = false;
        else
        {
            update(t,-1,2*n);
            update(off,1,2*n);
            mark[off] = m;
            prev[off] = t;
            off--;
        }
    }
    if(yes)
    {

        for(int i=1;i<=2*n;i++)
        {
            if(prev[off]!=UNKNOWN)
            {
                mark[prev[off] ] = mark[i];
            }
        }
        for(int i=n+1;i<=2*n;i++)
        {
            if(mark[i] == UNKNOWN)
            {
                cout<<(*s.begin())<<' ';
                s.erase(s.begin());
            }
            else
            {
                cout<<mark[i]<<' ';
            }
        }
        cout<<endl;
    }
    else
        cout<<"-1"<<endl;
    return 0;
}

//Template
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <numeric>
#include <functional>
#include <fstream>
#include <string>
#include <vector>
#include <bitset>
#include <cstdarg>
#include <complex>
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
#define pair(x, y) make_pair(x, y)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)

inline int read() {
	static int r, sign;
	static char c;
	r = 0, sign = 1;
	do c = getchar(); while (c != '-' && (c < '0' || c > '9'));
	if (c == '-') sign = -1, c = getchar();
	while (c >= '0' && c <= '9') r = r * 10 + (int)(c - '0'), c = getchar();
	return sign * r;
}

template <typename T>
inline void print(T *a, int n) {
	for (int i = 1; i < n; ++i) cout << a[i] << " ";
	cout << a[n] << endl;
}
#define PRINT(_l, _r, _s, _t) { cout << #_l #_s "~" #_t #_r ": "; for (int _i = _s; _i != _t; ++_i) cout << _l _i _r << " "; cout << endl; }

#define N 1000000

struct oper {
	int l, r, n, ans;
} q[N + 1];

inline bool cmp1(const oper &x, const oper &y) {
	return x.l < y.l;
}

inline bool cmp2(const oper &x, const oper &y) {
	return x.n < y.n;
}

int n, m, x[N + 1], y[N + 1], p[N + 1], pos[N + 1], seq[N + 1];

struct BIT {
	int arr[N + 1], n;

	inline void modify(int x, int v) {
		for (; x <= n; x += x & -x) arr[x] += v;
	}

	inline int query(int x) {
		int r = 0;
		for (; x > 0; x -= x & -x) r += arr[x];
		return r;
	}
} T, P;

int main(int argc, char *argv[]) {
#ifdef KANARI
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i)
		scanf("%d%d", x + i, y + i);
	for (int i = 1; i <= m; ++i) {
		p[i] = pos[x[i]];
		pos[x[i]] = i;
		q[i].l = p[i] + 1, q[i].r = i, q[i].n = i;
	}

	sort(q + 1, q + m + 1, cmp1);
	T.n = m;
	for (int i = 1, j = 1; i <= m; ++i) {
		if (p[i] > 0) T.modify(p[i], -1);
		T.modify(i, 1);
		while (j <= m && q[j].l == i) {
			q[j].ans = T.query(q[j].r);
			++j;
		}
	}

	sort(q + 1, q + m + 1, cmp2);
	P.n = n;
	for (int i = 1; i <= n; ++i) P.modify(i, 1);
	for (int i = 1; i <= n; ++i) pos[i] = 0;
	bool ok = true;
	for (int i = 1; i <= m; ++i) {
		if (pos[x[i]] != 0 && y[i] != q[i].ans) ok = false;
		if (pos[x[i]] == 0) {
			if (y[i] >= i) pos[x[i]] = P.query(y[i]);
			else printf("WTF? %d\n", i);
		}
		P.modify(i, -1);
		P.modify(y[i] + 1, 1);
	}
	if (!ok) printf("-1\n");
	else {
//		print(pos, n);
		for (int i = 1; i <= n; ++i)
			if (pos[i] != 0) seq[pos[i]] = i;
		for (int i = 1, j = 1; i <= n; ++i)
			if (seq[i] == 0) {
				while (j <= n && pos[j] != 0) ++j;
				seq[i] = j++;
			}
		for (int i = 1; i < n; ++i) printf("%d ", seq[i]);
		printf("%d\n", seq[n]);
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}

//#include <iostream>
//using std::cerr;
//using std::endl;

#include <cstdlib> // rand()

namespace treap {

struct Treap {
    Treap *l, *r;
    int pri, size, data;
    Treap(int d): l(), r(), pri(d/*std::rand()*/), size(1), data(d) {}
    ~Treap() { delete l; delete r; }
};

int size(Treap *t) {
    return t ? t->size : 0;
}
void pull(Treap* t){
    t->size = size(t->l) + size(t->r) + 1;
}
Treap* merge(Treap* a, Treap* b) {
    if(!a) return b;
    if(!b) return a;
    if(a->pri > b->pri) {
        a->r = merge(a->r, b);
        pull(a);
        return a;
    } else {
        b->l = merge(a, b->l);
        pull(b);
        return b;
    }
}
void split(Treap *t, int k, Treap*&a, Treap*&b){
    if(!t) a = b = 0;
    else if(size(t->l) <= k) {
        a = t;
        split(t->r, k, a->r, b); // XXX k ???
        pull(a);
    } else {
        b = t;
        split(t->l, k, a, b->l);
        pull(b);
    }
}
/*Treap* insert(Treap *t, int k, int data){
    Treap *a, *b;
    split(t, k, a, b);
    return merge(merge(a, new Treap(data)), b);
}*/
Treap* remove(Treap *t, int k){
//    if(t) cerr << "t " << t->data << endl; else cerr << "t null" << endl;
    Treap *a, *b, *c, *d;
    split(t, k - 1, a, b);
//    if(a) cerr << "a " << a->data << endl; else cerr << "a null" << endl;
//    if(b) cerr << "b " << b->data << endl; else cerr << "b null" << endl;
    split(b, k - size(a), c, d);
//    if(c) cerr << "c " << c->data << endl; else cerr << "c null" << endl;
//    if(d) cerr << "d " << d->data << endl; else cerr << "d null" << endl;
    delete c;
    return merge(a, d);
}
Treap* kth(Treap* t, int k){
//    cerr << "kth(" << t << ", " << k << ")" << endl;

    if(k < size(t->l))
        return kth(t->l, k);
    else if(k == size(t->l))
        return t;
    else
        return kth(t->r, k - size(t->l) - 1);
}

}

#include <cstdio>
#include <algorithm>

const int maxn = 1000000;

int val[maxn];
bool used[maxn];

using namespace treap;

int main(){
    int n, m;
    std::scanf("%d%d", &n, &m);
    Treap* treap = new Treap(0);
    for(int i = 1; i < n; i++)
        treap = merge(treap, new Treap(i));
    std::fill_n(val, n, -1);
//    for(int j = 0; j < size(treap); j++)
//        cerr << kth(treap, j)->data << " ";
//    cerr << endl;
    for(int i = 0; i < m; i++){
        int x, y;
        std::scanf("%d%d", &x, &y);
        x--;
        y--;
//        cerr << "kth..." << endl;
        int opos = kth(treap, y)->data;
        int fndval = val[opos];
        if(fndval != -1 && fndval != x){
//            cerr << "opos = " << opos << endl;
//            cerr << "fndval = " << fndval << endl;
            std::puts("-1");
            delete treap;
            return 0;
        }
        if(fndval == -1){
            if(used[x]){
//                cerr << x << " is used" << endl;
                std::puts("-1");
                delete treap;
                return 0;
            } else {
                used[x] = true;
                val[opos] = x;
            }
        }
//        cerr << "removing" << y << "..." << endl;
        treap = remove(treap, y);

//        for(int j = 0; j < size(treap); j++)
//            cerr << kth(treap, j)->data << " ";
//        cerr << endl;

//        cerr << "merging..." << endl;
        treap = merge(new Treap(opos), treap);

//        for(int j = 0; j < size(treap); j++)
//            cerr << kth(treap, j)->data << " ";
//        cerr << endl;

//        for(int j = 0; j < n; j++)
//            cerr << used[j] << " " << val[j] << endl;
    }
    for(int i = 0, j = 0; i < n; i++){
        int fnd = val[i];
        if(fnd == -1){
            while(used[j])
                j++;
            used[j] = true;
            fnd = j;
        }
        std::printf("%d%c", fnd + 1, i == n - 1 ? '\n' : ' ');
    }
    delete treap;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<ctime>

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(a) (int(a.size()))

using namespace std;

typedef struct item * pitem;
typedef long long int int64;
const int inf=1e9+7;

struct item {
    int prior,val,cnt;
    pitem l,r;
    item(int x){val=x,cnt=1,prior=1ll*rand()*rand()%inf,l=0,r=0;}
};
int cnt(pitem it){
    return it?it->cnt:0;
}
void upd_cnt (pitem it){
    if (it)
       it->cnt=cnt(it->l)+cnt(it->r)+1;
}
void merge(pitem &t,pitem l,pitem r){
    if (!l||!r)t=l?l:r;
    else if (l->prior > r->prior)
       merge (l->r,l->r,r),t=l;
    else
       merge (r->l,l,r->l),t=r;
    upd_cnt(t);
}
void split(pitem t,pitem &l,pitem &r,int key,int add=0){
    if (!t)
       return void(l=r=0);
    int cur_key=add+cnt(t->l);
    if (key <= cur_key)
       split (t->l,l,t->l,key,add),r=t;
    else
       split(t->r,t->r,r,key,add+1+cnt(t->l)),l=t;
    upd_cnt(t);
}
bool puton(pitem t,int key,int add,int x){
    int cur_key=add+cnt(t->l);
    if(key==cur_key){
        if(t->val==-1 || t->val==x){
            t->val=x;return 1;
        }
        else return 0;
    }
    if(key < cur_key)
        return puton(t->l,key,add,x);
    else return puton(t->r,key,add+1+cnt(t->l),x);
}

pair<int,int> q[1111111];
set<int> un;

void go(pitem t){
    if(!t)return;
    if(t->val==-1){
        t->val=*un.begin();
        un.erase(un.begin());
    }
    go(t->l);
    go(t->r);
}

void go2(pitem t){
    if(!t)return;
    go2(t->l);
    cout<<t->val<<' ';
    go2(t->r);
}
bool norm=1;
bool was[1111111];
void go3(pitem t){
    if(!t)return;
    go3(t->l);
    if(was[t->val])norm=0;was[t->val]=1;//cout<<t->val<<' ';
    go(t->r);
}

int main(){
    ios_base::sync_with_stdio(0);
    srand(time(NULL));
    int n,m;
    cin>>n>>m;
    pitem t=0;
    for(int i=1;i<=n;++i)
        merge(t,t,new item(-1)),un.insert(i);

    for(int i=1;i<=m;++i){
        cin>>q[i].F>>q[i].S;q[i].S--;
        if(un.count(q[i].F))un.erase(q[i].F);
        if(!puton(t,q[i].S,0,q[i].F)){
            cout<<-1;return 0;
        }
        pitem t1,t2,t3;
        split(t,t1,t2,q[i].S+1);
        split(t1,t1,t3,q[i].S);

        merge(t1,t3,t1);
        merge(t,t1,t2);
    }

    for(int i=m;i>=1;--i){
        if(!puton(t,0,0,q[i].F)){
            cout<<-1;return 0;
        }
        pitem t1,t2,t3;
        split(t,t1,t2,1);
        split(t2,t2,t3,q[i].S);

        merge(t2,t2,t1);
        merge(t,t2,t3);
    }
    go(t);
    go3(t);
    if(!norm)cout<<-1;
    else go2(t);

    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <iomanip>
#define ll long double
#define eps 1e-12
#define mp make_pair
#define pb push_back
#define inf 1e9
#define vi vector<long long>
#define vvi vector<vi>
#define vii vector<pair<long long,long long> >
#define vvii vector<vii>
using namespace std;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
}

struct node
{
	int prior;
	int cnt;
	int val;
	int fv;
	node* left;
	node* right;
	bool may;
	void update_count()
	{
		cnt = 1;
		if (left != 0)cnt += left->cnt;
		if (right != 0)cnt += right->cnt;
	}
	node() : val(0), prior(0), left(0), right(0), cnt(1),may(true),fv(0) {}
	node(int prior, int val, node *left = 0, node *right = 0) : prior(prior), val(-1), left(left), right(right),may(true),fv(val) {
		update_count();
	}
};

typedef node* pnode;

void split(pnode T, int key, pnode &l, pnode &r)
{
	if (T == 0)
	{
		l = r = 0;
		return;
	}
	if (key < T->cnt - (T->right == 0 ? 0 : T->right->cnt))
	{
		split(T->left, key, l, T->left);
		r = T;
		if (r)
			r->update_count();
	}
	else
	{
		split(T->right, key - (T->cnt - (T->right == 0 ? 0 : T->right->cnt)), T->right, r);
		l = T;
		if (l)
			l->update_count();
	}
}

void merge(pnode &t, pnode t1, pnode t2)
{
	if (t1 == NULL)
	{
		t = t2;
		return;
	}
	if (t2 == NULL)
	{
		t = t1;
		return;
	}
	if (t1->prior > t2->prior)
	{
		merge(t1->right, t1->right, t2);
		t = t1;
		if (t)
			t->update_count();
	}
	else
	{
		merge(t2->left, t1, t2->left);
		t = t2;
		if (t)
			t->update_count();
	}
}

int showweight(pnode &t, int key)
{
	if (t == 0)
		return 0;
	int l = 0, r = t->cnt;
	pnode n = 0, m = 0;

	while (r - l > 1)
	{
		int mm = (l + r) / 2;
		n = 0, m = 0;
		split(t, key + mm, n, m);
		if (n == 0)
		{
			t = 0;
			merge(t, n, m);
			r = mm;
			continue;
		}
		if (mm < n->cnt)
		{
			t = 0;
			merge(t, n, m);
			l = mm;
		}
		else
		{
			t = 0;
			merge(t, n, m);
			r = mm;
		}

	}
	n = 0, m = 0;
	split(t, key + l, n, m);
	if (n == 0)
	{
		t = 0;
		merge(t, n, m);
		return l;
	}
	if (l != n->cnt)
	{
		t = 0;
		merge(t, n, m);
		return r;
	}

	t = 0;
	merge(t, n, m);
	return l;
}

bool erase(pnode &t, int k,int a)
{
	if (t == 0)
		return -1;
	pnode l = 0, r = 0;
	split(t, k, l, r);
	pnode rr = 0;
	split(r, 1, rr, r);
	merge(t, r, l);
	if (rr->val == a)
	{
		merge(t, rr, t);
		return true;
	}
	if (rr->may)
	{
		rr->val = a;
		rr->may = false;
		merge(t, rr, t);
		return true;
	}
	return false;
}

void dfs(pnode t, vi &ans)
{
	if (t == 0)return;
	ans[t->fv - 1] = t->val;
	dfs(t->left, ans);
	dfs(t->right, ans);
}

vector<int> prior;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie();
	prepare();
	int n, m;
	cin >> n >> m;
	int kq = 0;
	prior.resize(n);
	for (int i = 0; i < prior.size(); i++)
		prior[i] = n - i;
	random_shuffle(prior.begin(), prior.end());

	pnode root = 0;
	for (int i = 0; i < n; i++)
	{
		pnode newt = new node(prior[kq++], i + 1);
		merge(root, root, newt);
	}
	for (int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		y--;
		if (erase(root, y, x))
			continue;
		else
		{
			cout << -1 << endl;
			return 0;
		}
	}
	vi ans(n);
	dfs(root, ans);
	set<int> ss;
	for (int i : ans)
	{
		if (i != -1)
		{
			if (ss.find(i) == ss.end())
				ss.insert(i);
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	int j = 1;
	for (int i = 0; i < ans.size(); i++)
	{
		if (ans[i] == -1)
		{
			for (; j <= n; j++)
				if (ss.find(j) == ss.end())
				{
					ans[i] = j; ss.insert(j); break;
				}
		}
	}

	for (int i : ans)
		cout << i << ' ';

	return 0;
}

// Mon Feb 01 2016 14:44:29 GMT+0300 (MSK)

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>

using namespace std;

const int maxn=1000000;

int s[maxn*2+1],ch[maxn*2+1][2],o[maxn+1],c[maxn+1],n,m,a,b,tt=0;

void reloc()
{
    freopen("/Users/admin/Desktop/cards.in","r",stdin);
    freopen("/Users/admin/Desktop/cards.out","w",stdout);
    return;
}

void buildtree(int l,int r)
{
    if(l>r)return;
    tt++;
    int now=tt;
    s[tt]=0;
    if(l==r)
    {
        ch[tt][0]=ch[tt][1]=0;
        return;
    }
    int mid=(l+r)/2;
    ch[tt][0]=tt+1;
    buildtree(l,mid);
    ch[now][1]=tt+1;
    buildtree(mid+1,r);
    return;
}

int findp(int root, int l,int r,int po)
{
    if(l==r)return l;
    int mid=(l+r)>>1;
    //printf("root=%d evaluation=%d goal=%d\n",root,mid+s[ch[root][1]],po);
    if(mid+s[ch[root][1]]==po)return mid;
    if(mid+s[ch[root][1]]>po)return findp(ch[root][0],l,mid,po-s[ch[root][1]]);
    else return findp(ch[root][1],mid+1,r,po);
}

void update(int root,int l,int r,int p)
{

    if(root==0)return;
    if(p<l||r<p)return;
    //printf("root=%d\n",root);
    s[root]++;
    if(l==r)return;
    int mid=(l+r)>>1;
    update(ch[root][0],l,mid,p);
    update(ch[root][1],mid+1,r,p);
    return;
}

void print()
{
    queue<int> q;
    for(int i=1;i<=n;i++)if(o[i]==0)q.push(i);
    for(int i=1;i<n;i++)
    {
        if(c[i]==0)
        {
            printf("%d ",q.front());
            q.pop();
        }
        else
        {
            printf("%d ",c[i]);

        }
    }
    int i=n;
    if(c[i]==0)
    {
        printf("%d\n",q.front());
        q.pop();
    }
    else
    {
        printf("%d\n",c[i]);

    }
    return;

}

void read()
{

    memset(c,0,sizeof(c));
    memset(s,0,sizeof(s));
    memset(o,0,sizeof(o));
    scanf("%d%d",&n,&m);
    buildtree(1,n);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a,&b);
        if(o[a]==0)
        {
            int p=findp(1,1,n,b);
            //cout<<p<<endl;
            update(1,1,n,p);
            o[a]=i;
            if(c[p])
            {
                cout<<-1<<endl;
                return;
            }
            c[p]=a;

        }
        else
        {
            int l=i-o[a];
            if(b!=l)
            {
                cout<<-1<<endl;
                return;
            }
        }
    }
    print();
    return;
}

int main()
{
    //reloc();
    read();
    return 0;
}

#include <bits/stdc++.h>

#pragma region shitcode
using namespace std;

using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using u32 = uint32_t;
using u64 = uint64_t;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> istream &operator >> (istream &s, vector<T> &v) { for (auto &i : v) s >> i; return s; }
template<typename A, typename B> istream &operator >> (istream &s, pair<A, B> &p) { return s >> p.first >> p.second; }

template<typename T> T gcd (T a, T b) { while (b) { a %= b; swap (a, b); } return a; }
template<typename T> T binpow (T a, T b, T mod) { T res = T (1); while (true) { if (b & T (1)) res = (res * a) % mod; b >>= T (1); if (!b) break; a = (a * a) % mod; } return res; }

template<typename T> uint64_t bubenhash64 (const T *first, const T *last) {
   static_assert (is_integral<T>::value && is_unsigned<T>::value && sizeof (T) <= sizeof (uint64_t), "Type should be an unsigned integer with size <= uint64_t");
   uint64_t res = 0x2545F4914F6CDD1D;
   while (first != last) {
      res += uint64_t (*first++);
      res ^= res << uint64_t (13);
      res ^= res >> uint64_t (7);
      res ^= res << uint64_t (17);
   }
   return res;
}

template<typename T> uint32_t bubenhash32 (const T *first, const T *last) {
   static_assert (is_integral<T>::value && is_unsigned<T>::value && sizeof (T) <= sizeof (uint32_t), "Type should be an unsigned integer with size <= uint32_t");
   uint32_t res = 0x4F6CDD1D;
   while (first != last) {
      res += uint32_t (*first++);
      res ^= res << uint32_t (13);
      res ^= res >> uint32_t (17);
      res ^= res << uint32_t (5);
   }
   return res;
}

#define all(X) X.begin (), X.end ()
#define f1(X) for (auto &i1 : X)
#define f2(X) for (auto &i2 : X)
#define f3(X) for (auto &i3 : X)
#define fi(n) for (int i = 0; i < int (n); i++)
#define fj(n) for (int j = 0; j < int (n); j++)
#define fk(n) for (int k = 0; k < int (n); k++)
#pragma endregion

struct cartesian {
public:
   struct node {
      node (int k, unsigned b, int v) : key (k), buben (b), value (v),
         subsize (1), l (nullptr), r (nullptr) {}
      int key, value;
      unsigned buben;
      int subsize;
      node *l, *r;
   };
   using pnode = node * ;

   cartesian () : root (nullptr), rng (0xDEADBEEF) {}

   pnode find (int key) {
      pnode cur = root;
      while (cur) {
         if (key == cur->key)
            return cur;
         cur = (key < cur->key ? cur->l : cur->r);
      }
      return nullptr;
   }

   bool insert (int key, int value) {
      if (find (key)) return false;
      insert (root, new node (key, rng (), value));
      return true;
   }
   bool erase (int key) { return erase (root, key); }

   int size () { return subsize (root); }
   int subsize (pnode t) { return t ? t->subsize : 0; }

   pnode kth_element (int k) {
      pnode cur = root;
      while (cur) {
         int lsize = subsize (cur->l);
         if (lsize > k) {
            cur = cur->l;
            continue;
         }
         k -= lsize;
         if (k-- == 0) return cur;
         cur = cur->r;
      }
      return nullptr;
   }

   int get_index (int key) {
      int idx = 0;
      pnode cur = root;
      while (cur) {
         if (key == cur->key)
            return idx + subsize (cur->l);
         else if (key < cur->key)
            cur = cur->l;
         else { idx += subsize (cur->l) + 1; cur = cur->r; }
      }
      return -1;
   }

//----
   void upd_subsize (pnode t) { if (t) t->subsize = 1 + subsize (t->l) + subsize (t->r); }

   void split (pnode t, int key, pnode &l, pnode &r) {
      if (!t) l = r = nullptr;
      else if (key < t->key) {
         split (t->l, key, l, t->l); r = t;
      }
      else { split (t->r, key, t->r, r); l = t; }
      upd_subsize (t);
   }

   void merge (pnode &t, pnode l, pnode r) {
      if (!l || !r) t = l ? l : r;
      else if (l->buben > r->buben) {
         merge (l->r, l->r, r); t = l;
      }
      else { merge (r->l, l, r->l); t = r; }
      upd_subsize (t);
   }

   void insert (pnode &t, pnode it) {
      if (!t) t = it;
      else if (it->buben > t->buben) {
         split (t, it->key, it->l, it->r);
         t = it;
      }
      else insert (it->key < t->key ? t->l : t->r, it);
      upd_subsize (t);
   }

   bool erase (pnode &t, int key) {
      if (!t) return false;
      bool res;
      if (t->key == key) {
         pnode tt = t;
         merge (t, t->l, t->r);
         delete tt;
         res = true;
      }
      else res = erase (key < t->key ? t->l : t->r, key);
      upd_subsize (t);
      return res;
   }

   pnode root;
   mt19937 rng;
};

struct cartesian_implicit {
public:
   struct node {
      node (unsigned b, int v) : buben (b), value (v),
         subsize (1), l (nullptr), r (nullptr) {}
      int value;
      unsigned buben;
      int subsize;
      node *l, *r;
   };
   using pnode = node * ;

   cartesian_implicit () : root (nullptr), rng (0xDEADBEEF) {}

   pnode at (int idx) {
      pnode cur = root;
      int add = 0;
      while (cur) {
         int cur_idx = add + subsize (cur->l);
         if (idx == cur_idx)
            return cur;
         else if (idx < cur_idx)
            cur = cur->l;
         else { cur = cur->r; add = cur_idx + 1; }
      }
      return nullptr;
   }

   void insert (int idx, int value) {
      pnode v = new node (rng (), value);
      pnode t1, t2;
      split (root, idx, t1, t2);
      merge (t1, t1, v);
      merge (root, t1, t2);
   }

   void set (int idx, int value) { set (root, idx, value); }

   void erase (int idx) { erase (root, idx); }

   int size () { return subsize (root); }
   int subsize (pnode t) { return t ? t->subsize : 0; }

//----
   void upd_node (pnode t) {
      if (!t) return;
      t->subsize = 1 + subsize (t->l) + subsize (t->r);
   }

   void split (pnode t, int idx, pnode &l, pnode &r, int add = 0) {
      if (!t) return void (l = r = nullptr);
      int cur_idx = add + subsize (t->l);
      if (idx <= cur_idx) {
         split (t->l, idx, l, t->l, add); r = t;
      }
      else { split (t->r, idx, t->r, r, cur_idx + 1); l = t; }
      upd_node (t);
   }

   void merge (pnode &t, pnode l, pnode r) {
      if (!l || !r) t = l ? l : r;
      else if (l->buben > r->buben) {
         merge (l->r, l->r, r); t = l;
      }
      else { merge (r->l, l, r->l); t = r; }
      upd_node (t);
   }

   void erase (pnode &t, int idx, int add = 0) {
      if (!t) return;
      int cur_idx = add + subsize (t->l);
      if (idx == cur_idx) {
         pnode tt = t;
         merge (t, t->l, t->r);
         delete tt;
      }
      else if (idx < cur_idx) erase (t->l, idx, add);
      else erase (t->r, idx, cur_idx + 1);
      upd_node (t);
   }

   void set (pnode t, int idx, int value, int add = 0) {
      if (!t) return;
      int cur_idx = add + subsize (t->l);
      if (idx == cur_idx)
         t->value = value;
      else if (idx < cur_idx) set (t->l, idx, value, add);
      else set (t->r, idx, value, cur_idx + 1);
      upd_node (t);
   }

   pnode root;
   mt19937 rng;
};

char used[1'000'000];
int next_used;

void dfs (cartesian_implicit::pnode cur) {
   if (!cur) return;
   dfs (cur->l);
   if (cur->value == -1) {
      while (used[next_used])
         next_used++;
      cur->value = next_used;
      used[next_used] = 1;
   }
   printf ("%d ", cur->value + 1);
   dfs (cur->r);
}

int main () {
#ifdef OFFLINE_JUDJE
   freopen ("input.txt", "r", stdin);
   //freopen ("output.txt", "w", stdout);
   atexit (__showTime);
#endif
   cin.sync_with_stdio (false);
   cout.sync_with_stdio (false);
   cin.tie (nullptr);

   cartesian_implicit tree;
   int n, m;
   //n = 1000000;
   //m = 1000000;
   scanf ("%d %d", &n, &m);
   fi (n) tree.insert (i, -1);
   vector<char> used (n);
   vector<int> acts (m);
   fi (m) {
      int x, y;
      //x = y = i;
      scanf ("%d %d", &x, &y);
      x--; y--;
      auto p = tree.at (y);
      if (p->value != -1 && p->value != x) {
         printf ("-1\n");
         return 0;
      }
      if (p->value == -1 && used[x]) {
         printf ("-1\n");
         return 0;
      }
      used[x] = 1;
      acts[i] = y;
      tree.erase (y);
      tree.insert (0, x);
   }
   reverse (all (acts));
   fi (m) {
      int y = acts[i];
      if (y == 0)
         continue;
      auto p = tree.at (0);
      int x = p->value;
      tree.erase (0);
      tree.insert (y, x);
   }
   dfs (tree.root);

   return 0;
}

///In the name of GOD
#include<bits/stdc++.h>
#define lc (id * 2)
#define rc (id * 2 + 1)
#define md ((s + e) / 2)
#define dm ((s + e) / 2 + 1)
#define ln (e - s + 1)
using namespace std;

typedef long long ll;
const ll MXN = 1e6 + 10;
const ll MXS = MXN * 4;
ll n, q;
ll A[MXN], Seg[MXS], Pos[MXS], Tf[MXS];
bool mark[MXN];
vector<ll> vec;
void Build(ll id = 1, ll s = 1, ll e = n){
    Pos[id] = s;
    if(ln == 1) return;
    Build(lc, s, md), Build(rc, dm, e);
}
void Go(ll val, ll ind, ll now, bool sit, ll id = 1, ll s = 1, ll e = n){
    if(ln == 1){
        bool Sit = sit ^ ((A[s] || s + now != ind));
        if(Sit){
            cout << "-1\n"; exit(0);
        }
        if(sit) return;
        A[s] = val, Pos[id] = Tf[id] = 1e13, Seg[id] = 1;
        return;
    }
    bool right = false;
    if(Pos[rc] + Tf[rc] + now <= ind) Go(val, ind, now, sit, rc, dm, e), right = true;
    else                              Go(val, ind, now + Seg[rc], sit, lc, s, md);
    Seg[id] = Seg[lc] + Seg[rc];
    if(Seg[id] == ln)               Pos[id] = Tf[id] = 1e13;
    else if(Seg[lc] == md - s + 1)  Pos[id] = Pos[rc], Tf[id] = Tf[rc];
    else                            Pos[id] = Pos[lc], Tf[id] = Tf[lc] + Seg[rc];
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> q, Build();
    while(q --){
        ll x, ind; cin >> x >> ind;
        if(mark[x]){
            Go(x, ind, 0, 1); continue;
        }
        mark[x] = 1;
        Go(x, ind, 0, 0);
    }
    for(int i = 1; i <= n; i ++){
        if(!mark[i]) vec.push_back(i);
    }
    for(int i = 1; i <= n; i ++){
        if(!A[i]) A[i] = vec.back(), vec.pop_back();
    }
    for(int i = 1; i <= n; i ++) cout << A[i] << ' '; cout << '\n';
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT  THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N

// macros {{{
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define BIT(n) ((1LL) << (long long)(n))
#define FOR(i,c) for (auto i=(c).begin(); i != (c).end(); ++i)
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define REP1(i,a,b) for (int i=(int)(a); i <= (int)(b); ++i)
#define MP make_pair
#define PB push_back

#define Fst first
#define Snd second

#ifdef WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int, int> PII;
typedef vector<int> VI;

#define runtime() ((double)clock() / CLOCKS_PER_SEC)

const double eps = 1e-7;
// }}}

#define MAX 1000005

int ans[MAX]; // ans[y] = x
int pre[MAX];

int BIT[MAX];

void add(int idx, int d)
{
    for (int i = idx + 3; i < MAX; i += i & (-i))
        BIT[i] += d;
}

int query(int idx)
{
    int cnt = 0;
    for (int i = idx + 3; i > 0; i -= i & (-i))
        cnt += BIT[i];
    return cnt;
}

int main()
{
    bool err = false;

    int n, m;
    scanf("%d %d", &n, &m);

    memset(ans, -1, sizeof(ans));
    memset(pre, -1, sizeof(pre));
    int cnt = 0;
    for (int i = 0; i < m and not err; ++i)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        --x, --y;

        if (pre[x] == -1) // first
        {
            int l = 0, r = n - 1; // fix r
            int found = -1;
            while (l <= r)
            {
                int mid = (l + r) / 2;

                int val = mid + cnt - query(mid-1);

                if (val <= y)
                    l = mid + 1, found = mid;
                else
                    r = mid - 1;
            }
            if (found == -1 or ans[found] != -1)
            {
                err = true;
                break;
            }
            ans[found] = x;
            add(found, 1);
            cnt ++;
        }
        else
        {
            if (y != (i-1) - pre[x]) err = true;
        }
        pre[x] = i;
    }
    if (err)
    {
        printf("-1");
        return 0;
    }

    queue<int> q;
    for (int i = 0; i < n; ++i)
        if (pre[i] == -1)
            q.push(i);

    for (int i = 0; i < n; ++i)
    {
        if (ans[i] == -1)
            ans[i] = q.front(), q.pop();

        printf("%d ", ans[i] + 1);
    }
}

#include"stdio.h"
#include"cassert"
#define M 1000000
#define N 1000000
#define DEBUG(x) ;

struct node {
	int color;
	int inc;
	node(): color(-1), inc(0) {}
} BIT[N+M+2];

bool used[N+1];

int lower_power_of_two(int i) {
	i --;
	i |= (i>>1);
	i |= (i>>2);
	i |= (i>>4);
	i |= (i>>8);
	i |= (i>>16);
	return (i+1)>>1;
}

int n, m;

void increment_bit(int pos, int inc) {
	while (pos <= m+n){
		BIT[pos].inc += inc;
		pos += (pos & -pos);
	}
}

int binary_search(int low, int hi, int sum) {
	assert(sum>0 and hi+1-low >= sum and low<=hi);
	if (low == hi) {
		assert(sum>0);
		return low;
	}
	int mid = lower_power_of_two(hi-(low-1)) + low-1;
	if(BIT[mid].inc < sum) {
		sum -= BIT[mid].inc;
		low = mid+1;
	} else {
		hi = mid;
	}
	return hi;
}

int binary_search(int sum) {
	// search for first position with prefix_sum = sum, i.e. locate teh sum^th glass in current queue
	int lower = 1, higher = n+m;
	return binary_search(lower, higher, sum);
}

int main() {
	scanf("%d%d", &n, &m);
	int front = m; // all glasses are at indices front+1, front + 2, ... m+n at any time
	for(int i=0; i<n; i++)
		increment_bit(m+1+i, 1);
	while(front>0) {
		int x, y;
		scanf("%d%d", &x, &y);
		int bit_pos = binary_search(y);
		DEBUG(("%d th cup is at pos %d\n", y, bit_pos));
		if (BIT[bit_pos].color<0) {
			BIT[bit_pos].color = x;
		} else if (BIT[bit_pos].color != x) {
			printf("-1");
			return 0;
		}
		increment_bit(front, 1); // place a glass here
		increment_bit(bit_pos, -1); // remove the glass from here
		BIT[front].color = BIT[bit_pos].color; //copy the color information
		front --;
	}
	for(int i=m+1; i<=m+n; i++) {
		if (BIT[i].color>0) {
			used[BIT[i].color] = 1;
		}
	}
	for(int i=m+1, next_free_color = 1; i<=m+n; i++) {
		if (BIT[i].color>0) {
			printf("%d ", BIT[i].color);
		} else {
			while(used[next_free_color]) next_free_color++;
			printf("%d ", next_free_color++);
		}
	}
}

#include <iostream>

using namespace std;

const int nmax = 1000005;

struct node
{
    int value;
    node *left, *right;
    node *parent;

    int height;
    int count;

    node(int value)
    {
        this->value = value;
        left = right = parent = NULL;
        height = count = 0;
    }
} *tree;

node *nodes[nmax];

int x[nmax];
int y[nmax];

bool used[nmax] = {};

int height(node *cur)
{
    return cur != NULL ? cur->height : 0;
}

int count(node *cur)
{
    return cur != NULL ? cur->count : 0;
}

void update(node *cur)
{
    if (cur != NULL)
    {
        cur->height = 1 + max(height(cur->left), height(cur->right));
        cur->count = 1 + count(cur->left), count(cur->right);
    }
}

node *left(node *cur)
{
    return cur != NULL ? cur->left : NULL;
}

node *right(node *cur)
{
    return cur != NULL ? cur->right : NULL;
}

void addLeft(node *a, node *b)
{
    a->left = b;
    if (b != NULL)
        b->parent = a;
}

void addRight(node *a, node *b)
{
    a->right = b;
    if (b != NULL)
        b->parent = a;
}

void rehang(node *a, node *b)
{
    node *parent = a->parent;
    if (!parent)
    {
        tree = b;
        tree->parent = NULL;
    }
    else if (parent->right == a)
        addRight(parent, b);
    else
        addLeft(parent, b);
}

void balance(node *cur)
{
    int hl = height(cur->left);
    int hr = height(cur->right);
    if (abs(hr - hl) <= 1)
        return;

    if (hr == hl + 2)
    {
        node *a = cur;
        node *b = right(cur);
        node *c = left(b);
        if (height(left(b)) <= height(right(b)))
        {
            rehang(a, b);
            addRight(a, left(b));
            addLeft(b, a);
        }
        else
        {
            rehang(a, c);
            addRight(a, left(c));
            addLeft(b, right(c));
            addLeft(c, a);
            addRight(c, b);
        }
        update(a);
        update(b);
        update(c);
        return;
    }
    if (hl == hr + 2)
    {
        node *a = cur;
        node *b = left(cur);
        node *c = right(b);
        if (height(right(b)) <= height(left(b)))
        {
            rehang(a, b);
            addLeft(a, right(b));
            addRight(b, a);
        }
        else
        {
            rehang(a, c);
            addLeft(a, right(c));
            addRight(b, left(c));
            addRight(c, a);
            addLeft(c, b);
        }
        update(a);
        update(b);
        update(c);
        return;
    }
    cout << "Something went wrong";
    return;
}

node *find(node *cur, int index)
{
    if (count(cur->left) >= index)
        return find(cur->left, index);
    else if (count(cur->left) + 1 == index)
        return cur;
    else
        return find(cur->right, index - count(cur->left) - 1);
}

int removeFirst(node *cur)
{
    if (cur->left == NULL)
    {
        rehang(cur, NULL);
        return cur->value;
    }
    int result = removeFirst(cur->left);
    update(cur);
    balance(cur);
    return result;
}

void insert(node *cur, int value, int index)
{
    if (count(cur->left) >= index)
    {
        if (cur->left)
            insert(cur->left, value, index);
        else
        {
            addLeft(cur, new node(value));
            update(cur->left);
        }
    }
    else
    {
        if (cur->right)
            insert(cur->right, value, index - count(cur->left) - 1);
        else
        {
            addRight(cur, new node(value));
            update(cur->right);
        }
    }
    update(cur);
    balance(cur);
}

int k;

void dfs(node *cur, node **nodes)
{
    if (cur->left)
        dfs(cur->left, nodes);

    nodes[k++] = cur;

    if (cur->right)
        dfs(cur->right, nodes);
}

int main()
{
    int n, m;

    cin >> n >> m;

    for (int i = n; i > 0; --i)
    {
        nodes[i] = new node(0);
        addLeft(nodes[i], 2 * i <= n ? nodes[2 * i] : NULL);
        addRight(nodes[i], 2 * i + 1 <= n ? nodes[2 * i + 1] : NULL);
        update(nodes[i]);
    }

    tree = nodes[1];

    for (int i = 0; i < m; ++i)
        cin >> x[i] >> y[i];

    bool ans = 1;
    for (int i = m - 1; i >= 0; --i)
    {
        removeFirst(tree);
        insert(tree, x[i], y[i] - 1);

        node *target = find(tree, y[i]);
        if (target->value != x[i] && target->value != 0)
            ans = 0;
        else
            target->value = x[i];
    }

    if (ans)
    {
        dfs(tree, nodes);
        for (int i = 0; i < n; ++i)
            if (nodes[i]->value != 0)
            {
                if (used[nodes[i]->value])
                {
                    ans = 0;
                    break;
                }
                used[nodes[i]->value] = 1;
            }
        if (ans)
        {
            int p = 1;
            for (int i = 0; i < n; ++i)
                if (nodes[i]->value == 0)
                {
                    while (used[p])
                        ++p;
                    nodes[i]->value = p;
                    used[p] = 1;
                }

            for (int i = 0; i < n; ++i)
                cout << nodes[i]->value << ' ';
            cout << '\n';
        }
    }

    if (!ans)
        cout << -1 << '\n';

    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _int64 long long

int d[5000000];
pair<int,int> dd[5000000];
int dy[1100000];
int used[1100000];
int next,n;

void add1(int x,int ll,int rr,int t,pair<int,int> p)
{
  int mid;
  if (rr==ll)
  {
    d[x]++;
    dd[x]=p;
    return;
  }
  mid=(ll+rr)/2;
  if (t<=mid) add1(x+x+1,ll,mid,t,p);
  else add1(x+x+2,mid+1,rr,t,p);
  d[x]++;
}

pair<int,int> get1(int x,int ll,int rr,int t)
{
  int mid;
  pair<int,int> p;
  if (ll==rr)
  {
    d[x]--;
    return dd[x];
  }
  mid=(ll+rr)/2;
  if (d[x+x+1]>=t) p=get1(x+x+1,ll,mid,t);
  else p=get1(x+x+2,mid+1,rr,t);
  d[x]--;
  return p;
}

int main()
{
  int i,j,m,x,y;
  pair<int,int> p;
  scanf("%d%d",&n,&m);
  memset(dy,-1,sizeof(dy));
  memset(d,0,sizeof(d));
  for (i=0;i<n;i++)
  {
    add1(0,0,(1<<21),(1<<20)+i,make_pair(i,-1));
  }
  next=-1;
  for (i=0;i<m;i++)
  {
    scanf("%d%d",&x,&y);
    p=get1(0,0,(1<<21),y);
    if ((p.second!=-1)&&(p.second!=x))
    {
      printf("-1\n");
      return 0;
    }
    p.second=x;
    dy[p.first]=x;
    add1(0,0,(1<<21),(1<<20)+next,p);
    next--;
  }
  for (i=0;i<n;i++)
    if (dy[i]!=-1)
    {
      if (used[dy[i]]!=0)
      {
        printf("-1\n");
        return 0;
      }
      used[dy[i]]=1;
    }
  j=1;
  for (i=0;i<n;i++)
  {
    if (dy[i]!=-1)
      printf("%d ",dy[i]);
    else
    {
      while (used[j]==1) j++;
      printf("%d ",j);
      j++;
    }
  }
  printf("\n");
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define n   2000005
#define CH  (ch=getchar())
#define For(i,a,b)  for(int i=a;i<=b;i++)

int     N,M,T,D,A[n],F[n],Ans[n];

int     IN(){
        int x=0,ch;
        for (;CH<'0'||ch>'9';);
        for (;ch>='0'&&ch<='9';CH)  (x*=10)+=ch-'0';
        return  x;
}

void    Add(int x,int k){
        for (;x<=T;x+=x&-x) F[x]+=k;
}
int     Ask(int x){
        int ret=0;  for (;x;x-=x&-x)    ret+=F[x];
        return  ret;
}
int     Kth(int k){
        int ret=0,tot=0;
        for (int i=19;i+1;i--)
        if  (ret+(1<<i)<=T&&tot+F[ret+(1<<i)]<k)
            ret+=1<<i,tot+=F[ret];
        return  ret+1;
}

int     main(){
        N=IN(); M=D=IN();   T=N+M;
        For(i,M+1,T)    Add(i,1);
        For(i,1,M)  {
            int x=IN(),y=IN(),k;
            if  (!A[x]){
                if  ((k=Kth(y))<=M) return  puts("-1"),0;
                Ans[k-M]=x; A[x]=k;
            }
            if  (Ask(A[x])!=y)  return  puts("-1"),0;
            Add(A[x],-1);   Add(A[x]=D--,1);
        }
        for (int i=1,j=1;i<=N;i++)  if  (!A[i]){
            for (;Ans[j];j++);  Ans[j++]=i;
        }
        For(i,1,N)  printf("%d ",Ans[i]);
}

//In the name of God
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int N = 1e6 + 6;

int n, m, ans[N], state[N], f[2 * N], x[N], y[N];
bool mark[N];

void update(int m, int c) { m = N - m - 2;
	while (m < N)
		f[m] += c, m += m & -m;
}
int query(int m) { m = N - m - 2;
	int res = 0;
	while (m)
		res += f[m], m -= m & -m;
	return res;
}
bool acc(int d, int cur) {
	int l = d + query(d + 1);
	if (l != cur)
		return l < cur;
	return ans[d] == -1;
}
void EXIT() {
	cout << -1 << '\n';
	exit(0);
}
int main() {
	fill(ans, ans + N, -1);
	scanf("%d%d", &n, &m);
	cerr << '\n';
	for (int i = 0; i < m; i++) {
		scanf("%d%d", x + i, y + i);
		if (mark[x[i]]++)
			continue;
		int st = 0, ed = n;
		while (ed - st > 1) {
			int mid = st + ed >> 1;
			(acc(mid, y[i])? st: ed) = mid;
		}
		if (acc(st, y[i])) {
			ans[st] = x[i];
			update(st, 1);
		}
		else
			EXIT();
	}
	for (int p1 = 1, p2 = 1; p1 <= n; p1++)
		if (!mark[p1]) {
			while (ans[p2] != -1)
				p2++;
			ans[p2] = p1;
		}
	for (int i = 1; i <= n; i++)
		state[ans[i]] = i;
	fill(f, f + 2 * N, 0);
	for (int i = 1; i <= n; i++)
		update(i, 1);
	for (int i = 0; i < m; i++)
		if (y[i] == n - query(state[x[i]] + 1)) {
			update(state[x[i]], -1);
			update(state[x[i]] = -i - 1, 1);
		}
		else
			EXIT();
	for (int i = 1; i <= n; i++)
		printf("%d ", ans[i]);
	printf("\n");
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

const int MAXN = 1000000;
int n, t[4*MAXN];
void build (int a[], int v, int tl, int tr) {
    if (tl == tr)
        t[v] = a[tl];
    else {
        int tm = (tl + tr) / 2;
        build (a, v*2, tl, tm);
        build (a, v*2+1, tm+1, tr);
    }
}

void update (int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        t[v] += add;
    else {
        int tm = (tl + tr) / 2;
        update (v*2, tl, tm, l, min(r,tm), add);
        update (v*2+1, tm+1, tr, max(l,tm+1), r, add);
    }
}

int get (int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get (v*2, tl, tm, pos);
    else
        return t[v] + get (v*2+1, tm+1, tr, pos);
}

struct item {
    int prior, cnt, add;
    int pos;
    ll key;
    item * l, * r;
    item() : l(nullptr), r(nullptr), cnt(0) { }
    item (int key, int prior) : key(key), prior(prior), l(nullptr), r(nullptr), cnt(0){ }
};
typedef item * pitem;

int cnt (pitem t) {
    return t ? t->cnt : 0;
}

void push (pitem it) {
    if (it && it->add) {
        if (it->l)  it->l->add = it->add;
        if (it->r)  it->r->add = it->add;
        it->add = 0;
    }
}

void upd_cnt (pitem t) {
    if (t)
        t->cnt = 1 + cnt(t->l) + cnt (t->r);
}

void upd_all (pitem t) {
    upd_cnt(t);
}

void merge (pitem & t, pitem l, pitem r) {
    if (!l || !r)
        t = l ? l : r;
    else if (l->prior > r->prior || (l->prior == r->prior && rand()%2))
        merge (l->r, l->r, r),  t = l;
    else
        merge (r->l, l, r->l),  t = r;
    upd_all (t);
}

void split (pitem t, pitem & l, pitem & r, ll key, int add = 0) {
    if (!t)
        return void( l = r = 0 );
    // int cur_key = add + cnt(t->l);
    if (key < t->key || (key==t->key && rand()%2))
        split (t->l, l, t->l, key, add),  r = t;
    else
        split (t->r, t->r, r, key, add),  l = t;
    upd_all (t);
}

void insert (pitem & t, pitem it) {
    if (!t)
        t = it;
    else if (it->prior > t->prior || (it->prior == t->prior && rand()%2))
        split (t, it->l, it->r, it->key),  t = it;
    else {
        if (it->key == t->key && rand() % 2) insert(t->l, it);
        else insert (it->key < t->key ? t->l : t->r, it);
    }
    upd_all (t);
}

void erase (pitem & t, ll key) {
    if (t->key == key)
        merge (t, t->l, t->r);
    else
        erase (key < t->key ? t->l : t->r, key);
    upd_all (t);
}

//pitem unite (pitem l, pitem r) {
//    if (!l || !r)  return l ? l : r;
//    if (l->prior < r->prior)  swap (l, r);
//    pitem lt, rt;
//    split (r, lt, rt, l->key);
//    l->l = unite (l->l, lt);
//    l->r = unite (l->r, rt);
//    return l;
//}

//void add (pitem t, int l, int r) {
//    pitem t1, t2, t3;
//    split (t, t1, t2, l);
//    split (t2, t2, t3, r-l+1);
//    t2->rev ^= true;
//    merge (t, t1, t2);
//    merge (t, t, t3);
//}

pitem search (pitem t, ll key) {
    if (t->key > key) {
        t->r->pos = t->pos + t->l->cnt + 1;
        return search(t->r, key);
    }
    else if (t->key < key) {
        t->l->pos = t->pos;
        return search(t->l, key);
    }
    else return t;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    int n,m;

    scanf("%d %d", &n, &m);
    vi ans(n,-1);
    vi a(n);
    forn(i,0,n) a[i]=i;
    build(a.data(),1,0,n-1);
    int pr = 0;
    vi where(n,-1);
    int cur = 0;
    std::vector<int> prior;
    for (int i=0; i<m; ++i) prior.push_back(i);
    std::random_shuffle (all(prior));
    vector<item> items(n);
    vi p(n,0);
    pitem root(nullptr);
    forn(i,0,m) {
        int x,y;
        scanf("%d %d", &x, &y);
        x--; y--;
        if(y>=pr) {

            // ne trogali
            if(where[x] >= 0) {
                cout<<-1;
                return 0;
            }
            int st = get(1,0,n-1,y);
            ans[st] = x;
            where[x] = st;
            p[x] = -cur;
            items[x].prior = prior[cur];
            items[x].key=p[x];
            insert(root, &items[cur]);
            cur++;
            pr++;
            update (1, 0, n-1, pr, y, 1);
        }
        else {
            if(where[x]==-1) {
                cout<<-1;
                return 0;
            }
            pitem test = search(root, p[x]);
            if(test->pos != y) {
                cout<<-1;
                return 0;
            }
            erase(root, p[x]);
            p[x] = -cur;
            items[x].prior = prior[cur];
            items[x].key=p[x];
            insert(root, &items[cur]);
            cur++;
        }
    }
    vi free;
    forn(i,0,n) if(where[i]==-1) free.pb(i);
    int pc = 0;
    forn(i,0,n) {
        if(ans[i] == -1) {
            ans[i] = free[pc];
            pc++;
        }
    }
    forn(i,0,n) printf("%d ", 1+ans[i]);

}

#include <bits/stdc++.h>

#define pb push_back
#define f first
#define s second

using namespace std;

const int N = 2e6 + 10;
const int md = 1e9 + 7;

int n, m;

int a[N];

int x[N];
int y[N];

int used[N];
int pos[N];

int t[N * 4];

vector <int> v;

int get(int v, int tl, int tr, int l, int r) {
    if (tl > r || l > tr) return 0;
    if (l <= tl && tr <= r) return t[v];
    int tm = (tl + tr) / 2;
    return get(v + v, tl, tm, l, r) + get(v + v + 1, tm + 1, tr, l, r);
}

void upd (int v, int tl, int tr, int pos, int x) {
    if (tl == tr) t[v] = x;
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm) upd(v + v, tl, tm, pos, x);
        else upd(v + v + 1, tm + 1, tr, pos, x);
        t[v] = t[v + v] + t[v + v + 1];
    }
}

int get1(int v, int tl, int tr, int b) {
    if (tl == tr) return tl;
    int tm = (tl + tr) / 2;
    if (tm + 1 + t[v + v + 1] <= b) return get1(v + v + 1, tm + 1, tr, b);
    else return get1(v + v, tl, tm, b - t[v + v + 1]);
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &x[i], &y[i]);
        if (!used[x[i]]) {
            pos[x[i]] = get1(1, 1, n, y[i]) + m;
            a[pos[x[i]]] = x[i];
            upd(1, 1, n, pos[x[i]], 1);
        }
        used[x[i]] = 1;
    }
    for (int i = 1; i <= n; i++) {
        if (!used[i]) v.pb(i);
    }
    int it = 0;
    for (int i = 1; i <= n; i++) {
        if (!a[i]) {
            if (it == int(v.size())) return cout << -1, 0;
            a[i] = v[it];
            pos[a[i]] = m + i;
            it++;
        }
    }
    for (int i = 0; i <= 2000000; i++) t[i] = 0;
    int cur = m;
    for (int i = 1; i <= n; i++) {
        upd(1, 1, n + m, pos[i], 1);
    }
    for (int i = 1; i <= m; i++) {
        int sum = get(1, 1, n + m, 1, pos[x[i]]);
        if (sum != y[i]) return cout << -1, 0;
        upd(1, 1, n + m, pos[x[i]], 0);
        pos[x[i]] = cur;
        upd(1, 1, n + m, pos[x[i]], 1);
        cur--;
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << ' ';
    }
    return 0;
}

#include <bits/stdc++.h>

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

struct _nd {
    _nd *l, *r;
    int p, v, s;

    _nd() : l(0), r(0), p(rand()), v(0), s(1) {}

    void fix() {
        s = 1;
        if (l) s += l->s;
        if (r) s += r->s;
    }
};
typedef _nd *nd;

nd merge(nd a, nd b) {
    if (!a) return b;
    if (!b) return a;
    if (a->p > b->p) {
        a->r = merge(a->r,b);
        a->fix();
        return a;
    } else {
        b->l = merge(a,b->l);
        b->fix();
        return b;
    }
}

pair<nd,nd> split(nd a, int p) {
    if (!a) return make_pair(a,a);
    int ls = 0;
    if (a->l) ls += a->l->s;
    nd x, y;
    if (p <= ls) {
        tie(x,y) = split(a->l,p);
        a->l = y;
        a->fix();
        return {x,a};
    } else {
        tie(x,y) = split(a->r,p-ls);
        a->r = x;
        a->fix();
        return {a,y};
    }
}

int p[1000005];
int u[1000005];

int main() {
    int n, m; scanf("%d%d", &n, &m);
    nd root = new _nd;
    FO(i,0,n) {
        nd d = new _nd;
        d->v = i;
        root = merge(root,d);
    }
    FO(i,0,m) {
        int v, l; scanf("%d %d", &v, &l);
        nd a,b,c;
        tie(a,b) = split(root,l-1);
        tie(b,c) = split(b,1);

        int oi = b->v;
        if (p[oi] == 0) {
            if (u[v]) {
                printf("-1\n");
                return 0;
            }
            p[oi] = v;
            u[v] = 1;
        }
        if (p[oi] != v) {
            printf("-1\n");
            return 0;
        }
        root = merge(merge(b,a),c);
    }

    int uu = 1;
    FO(i,0,n) {
        if (!p[i]) {
            while (u[uu]) uu++;
            u[uu] = 1;
            p[i] = uu;
        }
        printf("%d%c", p[i], " \n"[i+1==n]);
    }
}

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<vector>
#define MAXN 1000005
using namespace std ;
typedef long long LL ;

struct point {
	int x, at ;
} s[MAXN] ;

int N, M, head, now ;
int son[MAXN][2], fa[MAXN] ;
int sum[MAXN], num[MAXN] ;
int vis[MAXN] ;

void Update(int x)
{
	sum[x] = sum[son[x][0]]+sum[son[x][1]]+1 ;
}
void Rotate(int x, int d)
{
	int tmp = fa[x] ;
	son[tmp][d^1] = son[x][d], fa[son[x][d]] = tmp ;
	if(fa[tmp]) son[fa[tmp]][son[fa[tmp]][1] == tmp] = x ;
	fa[x] = fa[tmp], fa[tmp] = x, son[x][d] = tmp ;
	Update(tmp), Update(x) ;
}
void Splay(int x, int to)
{
	int tmp, d1, d2 ;
	while((tmp=fa[x]) != to)
	{
		if(fa[tmp] == to) Rotate(x, son[tmp][0]==x) ;
		else if((d1=(son[fa[tmp]][0]==tmp)) == (d2=(son[tmp][0]==x)))
			Rotate(tmp, d1), Rotate(x, d2) ;
		else Rotate(x, d2), Rotate(x, d1) ;
	}
}
void Delete(int x)
{
	Splay(x, 0) ;
	if(!(son[x][0]+son[x][1])) return ;
	son[x][1] = fa[son[x][1]] = 0 ;
	sum[x] = 1 ;
}
int Ask(int x, int k)
{
	int tmp = 0 ;
	for(x;x;)
		if(sum[son[x][0]]+1 == k) break ;
		else if(sum[son[x][0]]+1<k)
			k -= sum[son[x][0]]+1, x = son[x][1] ;
		else x = son[x][0] ;
	return x ;
}
void Dfs(int x)
{
	if(son[x][0])
		Dfs(son[x][0]) ;
	if(num[x] == -1)
	{
		while(vis[now]) now ++ ;
		vis[now] = 1, num[x] = now ;
	}
	printf("%d ", num[x]) ;
	if(son[x][1])
		Dfs(son[x][1]) ;
}
void Fail()
{
	printf("-1\n") ;
	//system("pause") ;
	exit(0) ;
}

int main()
{
	int i, j, tmp, lt, rt ;
	int type, fr, to ;
	scanf("%d %d", &N, &M) ;
	for(i = 1; i <= M; i ++)
		scanf("%d %d", &s[i].x, &s[i].at) ;
	head = N, sum[N] = 1, num[N] = -1 ;
	for(i = N-1; i >= 1; i --)
	{
		Splay(head, 0) ;
		son[head][0] = i, fa[i] = head, sum[i] ++, sum[head] ++ ;
		num[i] = -1, head = i ;
	}
	for(i = M; i; i --)
	{
		if(num[head] >= 0 && num[head] != s[i].x) Fail() ;
		num[head] = s[i].x, vis[s[i].x] = 1 ;
		if(s[i].at == 1) continue ;
		else
		{
			Splay(head, 0) ;
			lt = Ask(head, s[i].at) ;
			rt = Ask(head, s[i].at+1) ;
			Delete(head), Splay(lt, 0) ;
			if(rt) {Splay(rt, lt), son[rt][0] = head, fa[head] = rt, sum[lt]++, sum[rt]++ ;}
			else {son[lt][1] = head, fa[head] = lt, sum[lt]++ ;}
			Splay(lt, 0), head = Ask(lt, 1) ;
		}
	}
	now = 1 ;
	Splay(head, 0), Dfs(head) ;
	//system("pause") ;
	return 0 ;
}

#pragma comment(linker, "/STACK:256000000")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <functional>
#include <cstring>
#include <set>
#include <map>
#include <ctime>
#include <cassert>
#include <cinttypes>

using namespace std;

const int N = 1000100;

int n, m;
int num[N];
int x[N], y[N];
bool used[N];
int f[N];

int mrand()
{
	return rand() ^ (rand() << 15);
}

struct node
{
	int val;
	int sz;
	int l, r;
	int y;

	node() : val(0), sz(1), l(0), r(0), y(mrand()) { }
} tree[N];

void tupdate(int t)
{
	if (!t) return;
	tree[t].sz = 1;
	const int l = tree[t].l;
	const int r = tree[t].r;
	if (l)
		tree[t].sz += tree[l].sz;
	if (r)
		tree[t].sz += tree[r].sz;

}

int merge(int l, int r)
{
	if (!l) return r;
	if (!r) return l;
	if (tree[l].y > tree[r].y)
	{
		tree[l].r = merge(tree[l].r, r);
		tupdate(l);
		return l;
	} else {
		tree[r].l = merge(l, tree[r].l);
		tupdate(r);
		return r;
	}
}

void split(int t, int sz, int& l, int &r)
{
	if (!t)
	{
		l = r = 0;
		return;
	}
	const int tl = tree[t].l;
	const int tr = tree[t].r;
	const int tl_sz = tl ? tree[tl].sz : 0;
	if (tl_sz >= sz)
	{
		r = t;
		split(tl, sz, l, tree[t].l);
	} else {
		l = t;
		split(tr, sz - tl_sz - 1, tree[t].r, r);
	}
	tupdate(l);
	tupdate(r);
}

void update(int i, int val)
{
	for (; i < N; i = (i | (i + 1)))
		f[i] += val;
}

int sum(int i)
{
	int ret = 0;
	for (; i >= 0; i = (i & (i + 1)) - 1)
		ret += f[i];
	return ret;
}

void read()
{
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i)
		scanf("%d %d", x + i, y + i);
}

bool go()
{
	int pref = 0;
	for (int i = 0; i < m; ++i)
	{
		if (y[i] <= pref)
		{
			if (!used[x[i]])
				return false;
			continue;
		}
		if (used[x[i]])
			return false;
		++pref;
		used[x[i]] = true;
		int shift = sum(N - 1 - y[i]);
		if (y[i] + shift < 1)
			return false;
		if (num[y[i] + shift])
			return false;
		num[y[i] + shift] = x[i];
		update(N - 1 - y[i], - 1);
	}
	for (int i = 1, j = 1; i <= n; ++i)
	{
		if (num[i]) continue;
		while (j < n && used[j])
			++j;
		if (j == n + 1) return false;
		num[i] = j;
		++j;
	}
	return true;
}

bool check()
{
	int root = 0;
	for (int i = 1; i <= n; ++i)
	{
		tree[i].val = num[i];
		root = merge(root, i);
	}
	for (int i = 0; i < m; ++i)
	{
		int l, r, mid;
		split(root, y[i] - 1, l, r);
		split(r, 1, mid, r);
		if (tree[mid].val != x[i])
			return false;
		l = merge(mid, l);
		root = merge(l, r);
	}
	return true;
}

void print()
{
	for (int i = 1; i <= n; ++i)
		printf("%d ", num[i]);
	printf("\n");
}

int main()
{
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	read();
	if (go() && check())
		print();
	else
		cout << -1 << endl;
	return 0;
}

// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e6 + 5;

int n, m, A[N], M[N], P[N << 1], SEG[N << 3], LAZY[N << 3];

#define md (s + e) >> 1
#define lc id << 1
#define rc lc ^ 1
void Apply(int id, int x) { SEG[id] += x, LAZY[id] += x; }
void Shift(int id) {
	if (!LAZY[id]) return;
	Apply(lc, LAZY[id]), Apply(rc, LAZY[id]);
	LAZY[id] = 0;
}
void Update(int l, int r, int x, int id = 1, int s = 0, int e = n + m) {
	if (l >= e || s >= r) return;
	if (l <= s && e <= r) return Apply(id, x);
	Shift(id);
	Update(l, r, x, lc, s, md), Update(l, r, x, rc, md, e);
	SEG[id] = max(SEG[lc], SEG[rc]);
}
int Get(int x, int id = 1, int s = 0, int e = n + m) {
	if (e - s < 2) return s;
	Shift(id);
	if (SEG[lc] >= x) return Get(x, lc, s, md);
	else return Get(x, rc, md);
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	cin >> n >> m;
	for (int i = 1; i <= n; i++) Update(m + i - 1, m + i, i), P[m + i - 1] = i;
	for (int i = 1; i <= m; i++) {
		int x, y; cin >> x >> y;
		int k = Get(y);
		if (M[x] && M[x] != P[k]) die(-1);
		M[x] = P[m - i] = P[k];
		Update(k, k + 1, -k);
		Update(m - i, k, +1);
	}
	vector<int> V;
	for (int i = 1; i <= n; i++) {
		if (!M[i]) V.push_back(i);
		else if (A[M[i]]) die(-1);
		else A[M[i]] = i;
	}
	reverse(all(V));
	for (int i = 1; i <= n; i++) {
		if (A[i]) cout << A[i] << ends;
		else cout << V.back() << ends, V.pop_back();
	}
	cout << endl;

	return 0;
}

#ifdef LOCAL
#include <fstream>
using namespace std;
ifstream cin("input.txt");
ofstream cout("output.txt");
#else // LOCAL
#include <iostream>
#endif

#include <math.h>
#include <map>
#include <vector>
#include <set>
#include <deque>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef
tree <
pair<int, int>,
     null_type,
     less<pair<int, int>>,
     rb_tree_tag,
     tree_order_statistics_node_update >
     ordered_set;

#define ull unsigned long long
#define ll long long
#define pii pair<int,int>

struct Treap {
	int key;
	int prior;
	int pos;
	int size;
	int val;
	Treap * l;
	Treap * r;
	Treap(int val) {
	    this->val = -1;
	    l = nullptr;
	    r = nullptr;
		this->prior = rand();
		size = 1;
		this->pos = val;
	}

};

void update_size(Treap  * &t) {
    if(t==nullptr)
        return;
	t->size = (t->l!=nullptr ? t->l->size : 0) + (t->r!=nullptr ? t->r->size : 0) + 1;
	int adasd = t->size;
}

Treap * merge(Treap * tl, Treap * tr) {
	//ALL VALS INT TR IS NOT LESS THAN IN TL
	if (tl == nullptr)
		return tr;
	if (tr == nullptr)
		return tl;

	if (tl->prior > tr->prior) {
		tl->r = merge(tl->r, tr);
		update_size(tl);
		return tl;
	} else {
		tr->l = merge(tl, tr->l);
		update_size(tr);
		return tr;
	}
}

void split(Treap * t, int key, Treap *& tl, Treap *& tr) {
	if (t == nullptr) {
		tl = nullptr;
		tr = nullptr;
		return;
	}

	int l = t->l!= nullptr ? t->l->size : 0;

	if (key > l) {
		split(t->r, key - l - 1, tl, tr);
		t->r = tl;
		update_size(t);
		tl = t;
	} else {
		split(t->l, key, tl, tr);
		t->l = tr;
		update_size(t);
		tr = t;
	}

}

int tests() {
	Treap * tree = new Treap(0);
	int pr =  tree->prior;
	for (int i = 1; i < 5; i++) {
        Treap * to_merge = new Treap(i);
        int asd = to_merge->prior;
		tree = merge(tree, to_merge);
	}
	int ddd = tree->size;
    Treap * tl;
    Treap * tr;
    split(tree,2,tl,tr);
    Treap * tl2;
    Treap * tr2;
    split(tr,1,tl2,tr2);
    int ksdf = tl->val;

	exit(0);
}

vector<pii> ans;

void dfs(Treap * t){
    if(t==nullptr)
        return;
    ans.push_back({t->pos,t->val});
    dfs(t->l);
    dfs(t->r);
}

void error(){
    printf("-1");
    exit(0);
}

vector<unsigned char> used;

int main() {
    cin.sync_with_stdio(false);
	//tests();
	Treap * tree = new Treap(1);
	int n, m;
	cin >> n >> m;
	used.resize(n+10);
	for (int i = 2; i <= n; i++) {
        Treap * v = new Treap(i);
		tree = merge(tree, v);
	}

	for (int i = 0; i < m; i++) {
		int val, pos;
		scanf("%d%d",&val,&pos);
		cin >> val >> pos;
		Treap * tl1;
		Treap * tr1;

		split(tree, pos-1, tl1, tr1);

		Treap * tl2;
		Treap * tr2;
		split(tr1, 1, tl2, tr2);

//		int ls = tl1->size;
//		int rs = tr1->size;

        if(tl2->val != -1 && tl2->val != val)
            error();
        if(tl2->val == -1 && used[val]==1)
            error();

		tl2->val = val;
		used[val] = 1;

		tree = merge(tl2, tl1);
        tree = merge(tree,tr2);
	}
	dfs(tree);
	sort(ans.begin(),ans.end());
	deque<int> not_used;
    for(int i = 1; i <= n; i++){
        if((int)used[i]==0)
            not_used.push_back(i);
    }
    for(auto& i :ans){
            if(i.second==-1){
                printf("%d ",(int)not_used[0]);
//                cout << (int)not_used[0] << ' ';
                not_used.pop_front();
            }else
            printf("%d",i.second);
    }
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:167777216")
#include <cmath>
#include <math.h>
#include <complex>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#include <unordered_map>
#include <stack>
#include <time.h>
#include <fstream>
#include <queue>
using namespace std;

#define pb push_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second

#define all(x) x.begin(), x.end()
#define sqr(x) ((x)*(x))
#define eps 1e-9
#define M_PI       3.14159265358979323846
#define PI       3.14159265358979323846
typedef long long ll;
typedef  unsigned long long ull;
typedef  long double ld;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef int huint;
const ll Mll = 1000000000000000000;
const ll Mint = 1000000000;

ll mod = 1000000007;

struct treap
{
    treap *l{ nullptr }, *r{ nullptr };
    int k, y, x;
    treap()
    {
        x = 0, y = 0, k = 0;
        r = l = nullptr;
    }
    treap(ll x1, ll y1)
    {
        x = x1, y = y1;
    }
    void calc()
    {
        if (this == nullptr) return;
        k = 1;
        if (r != nullptr) k += r->k;
        if (l != nullptr) k += l->k;
    }
};
void merge(treap* &T, treap* L, treap* R)
{
    if (L == nullptr)
    {
        T = R; T->calc();
        return;
    }
    if (R == nullptr)
    {
        T = L; T->calc();
        return;
    }
    if (L->y > R->y)
    {
        merge(L->r, L->r, R);
        T = L;
    }
    else
    {
        merge(R->l, L, R->l);
        T = R;
    }
    T->calc();
}
void split(treap* T, treap* &L, treap* &R, int k)
{
    if (T == nullptr)
    {
        L = R = nullptr;
        return;
    }
    int kl = 0;
    if (T->l != nullptr) kl = T->l->k;
    if (kl >= k)
    {
        split(T->l, L, T->l, k);
        R = T;
        R->calc();
    }
    else
    {
        split(T->r, T->r, R, k - kl - 1);
        L = T;
        L->calc();
    }
}

vector<int> p;
void dfs(treap* v)
{
    if (v == nullptr) return;
    dfs(v->l);
    //  cout << v->x << " ";
    p.pb(v->x);
    dfs(v->r);
}
void dfs1(treap* v)
{
    if (v == nullptr) return;
    dfs1(v->l);
 //   cout << v->x << " ";
 printf("%d ", v->x);
    //p.pb(v->x);
    dfs1(v->r);
}
int f[1001000];

int g[1001000];

int readInt() {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch - '0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result * 10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int main()
{
    srand(time(NULL));

  //  freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    treap* root;
    root = nullptr;
    int n, m;
    cin >> n >> m;
    for (int i(1); i <= n; i++)
    {
        treap* a = new treap(-1, rand());
        merge(root, root, a);
    }
    for (int i(0); i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
    //    a = readInt();
     //   b = readInt();
        g[i] = b;
        treap *x, *y, *z, *q;
        split(root, x, y, b);
        split(x, q, z, b - 1);
        if (f[a] != 0 && z->x != a)
        {
            cout << -1; return 0;
        }
        if (z->x != a && z->x != -1)
        {
            cout << -1; return 0;
        }
        z->x = a;
        merge(root, z, q);
        merge(root, root, y);

    }
    if (n == m && n == 1000000) return 0;
    dfs(root);
    int k = 0, ind = -1;
    for (int i(0); i < p.size(); i++)
        if (p[i] == -1) k++;
        else
        {
            if (f[p[i]] == -1)
            {
                cout << -1; return 0;
            }
            f[p[i]] = -1;
        }
    int j = 1;
    for (int i(0); i < p.size(); i++)
    {
        if (p[i] != -1) continue;
        while (j <= n && f[j] == -1) j++;
        if (j > n)
        {
            cout << -1; return 0;
        }
        f[j] = -1;
        p[i] = j;
    }
    if (ind != -1) p[ind] = j;

    if (n == m && n == 1000000) return 0;

    treap* nroot = nullptr;
    for (int i(0); i < p.size(); i++)
    {
        treap* a = new treap(p[i], rand());
        merge(nroot, nroot, a);
    }

    for (int i(m - 1); i >= 0; i--)
    {
        int k = g[i] - 1;
        treap *x, *y, *z, *q;
        split(nroot, x, y, 1);
        split(y, z, q, k);
        merge(nroot, z, x);
        merge(nroot, nroot, q);
    }
    dfs1(nroot);
}

#include <bits/stdc++.h>

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

struct Node {
    int add, lnum;

    Node() : add(0), lnum(0) {}
};

const int N = 1000005;
Node tree[4 * N];
int arr[N], perm[N], prv[N];

void build(int i, int l, int r) {
    if (l == r) {
        tree[i].add = tree[i].lnum = arr[l];
        return;
    }
    build(2 * i, l, (l + r) / 2);
    build(2 * i + 1, (l + r) / 2 + 1, r);
    tree[i].add = 0;
    tree[i].lnum = tree[2 * i].lnum;
}

void push(int i) {
    tree[2 * i].add += tree[i].add;
    tree[2 * i].lnum += tree[i].add;
    tree[2 * i + 1].add += tree[i].add;
    tree[2 * i + 1].lnum += tree[i].add;
    tree[i].add = 0;
}

void update(int i, int l, int r, int a, int b, int val) {
    if (r < a || b < l) {
        return;
    }
    if (a <= l && r <= b) {
        tree[i].add += val;
        tree[i].lnum += val;
        return;
    }
    push(i);
    update(2 * i, l, (l + r) / 2, a, b, val);
    update(2 * i + 1, (l + r) / 2 + 1, r, a, b, val);
    tree[i].lnum = tree[2 * i].lnum;
}

int query(int i, int l, int r, int val) {
    if (l == r) {
        return tree[i].lnum == val ? l : -1;
    }
    push(i);
    if (tree[2 * i + 1].lnum <= val) {
        return query(2 * i + 1, (l + r) / 2 + 1, r, val);
    }
    return query(2 * i, l, (l + r) / 2, val);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        arr[i] = i;
    }
    build(1, 1, n);
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        if (prv[a]) {
            if (i - prv[a] != b) {
                cout << "-1\n";
                return 0;
            }
        } else {
            int p = query(1, 1, n, b);
            if (p == -1) {
                cout << "-1\n";
                return 0;
            }
            perm[p] = a;
            update(1, 1, n, 1, p, 1);
        }
        prv[a] = i;
    }
    for (int i = 1, j = 1; i <= n; i++) {
        if (perm[i] == 0) {
            while (prv[j]) {
                j++;
            }
            perm[i] = j++;
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << perm[i] << " ";
    }
    cout << "\n";
}

#include <cstdlib>
#include <cstring>
#include <memory>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <cmath>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)

#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ZERO(a) memset(a,0,sizeof(a))
void _fill_int(int* p,int val,int rep) {int i;  FOR(i,rep) p[i]=val;}
#define FILL_INT(a,val) _fill_int((int*)a,val,sizeof(a)/4)
#define MINUS(a) _fill_int((int*)a,-1,sizeof(a)/4)
ll GETi() { ll i;scanf("%lld",&i); return i;}
//-------------------------------------------------------

int N,M;
int num[1000002];
int used[1000002];
vector<int> V[3000];

void solve() {
    int f,i,j,k,l,x,y;

    cin>>N>>M;

    FOR(i,N) V[i/1000].push_back(i);

    FOR(i,M) {
        cin>>x>>y;
        FOR(j,3000) {
            if(y<=V[j].size()) break;
            y-=V[j].size();
        }
        y--;
        k=V[j][y];
        if(num[k]!=0 && num[k]!=x) return _P("-1\n");
        if(num[k]==0 && used[x]) return _P("-1\n");
        num[k]=x;
        used[x]=1;

        V[j].erase(V[j].begin()+y);
        if(V[0].size()>1000) {
            FOR(j,2999) V[j+1]=V[j];
            V[0].clear();
            V[0].push_back(k);
        }
        else {
            V[0].resize(V[0].size()+1);
            for(j=V[0].size()-1;j>=1;j--) V[0][j]=V[0][j-1];
            V[0][0]=k;
        }
    }

    x=1;
    FOR(i,N) {
        while(used[x]) x++;
        if(num[i]==0) num[i]=x++;
        _P("%d ",num[i]);
    }
    _P("\n");
}

int main(int argc,char** argv){
    string s;
    if(argc==1) ios::sync_with_stdio(false);
    for(int i=1;i<argc;i++) s+=argv[i],s+='\n';
    for(int i=s.size()-1;i>=0;i--) ungetc(s[i],stdin);
    solve();
    return 0;
}

#ifndef _DEBUG
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#ifdef _DEBUG
ifstream cin("input.txt");
ofstream cout("output.txt");
#endif
typedef long long LL;
//typedef long double LL;
double eps = 1e-9;
const LL INF = 1e9;
LL mod = 1e9 + 7;

struct node
{
	node* left;
	node* right;
	LL key;
	LL w;
	LL cnt;
	LL prior;
	LL num;
	node(LL k, LL p, LL wei = 0, LL num1 = 0)
	{
		key = k;
		prior = p;
		w = wei;
		left = nullptr;
		right = nullptr;
		cnt = 0;
		num = num1;
	}
};
typedef node* pnode;
pnode tree;
LL cnt(pnode t)
{
	return t ? t->cnt:0;
}
void update_cnt(pnode t)
{
	if(t)
		t->cnt = 1 + cnt(t->left) + cnt(t->right);
}
void split(pnode tree, LL key, pnode& left, pnode& right,LL superkey = 0)
{
	if(tree == nullptr)
	{
		left = right = nullptr;
	}
	else
	{
		LL s = 1 + superkey + cnt(tree -> left);
		if(key <= s)
		{
			split(tree -> left, key, left, tree->left, superkey);
			right = tree;
		}
		else
		{
			split(tree->right, key, tree->right, right, s);
			left = tree;
		}
	}
	update_cnt(tree);
}

void insert(pnode& tree, pnode elem)
{
	if(tree == nullptr)
		tree = elem;
	else if(tree -> prior < elem->prior)
		split(tree, elem->key, elem->left, elem->right), tree = elem;
	else
		insert(elem->key < tree->key? tree->left:tree->right ,elem);
	update_cnt(tree);
}
void merge(pnode& tree, pnode & l, pnode& r)
{
	if(!r || !l)
	{
		tree = l? l:r;
	}
	else if(l->prior > r->prior)
		merge(l->right, l->right, r), tree = l;
	else
		merge(r->left, l, r->left), tree = r;
	update_cnt(tree);
}
void find(pnode& res, pnode t, LL key, LL  superkey = 0)
{
	LL s = 1 + superkey + cnt(t->left);
	t->w = s;
	if(!t)
	{
		res = t;
		return;
	}
	if(key < t->key)
	{
		find(res, t->left, key, superkey);
	}
	else
		if(key > t->key)
		{
			find(res, t->right, key, s);
		}
		else
		{
			res = t;
			return;
		}
}
void erase(pnode& t, int key)
{
	if(!t)
		return;
	if(t->key == key)
		merge(t, t->left, t->right);
	else
		erase(key < t->key ? t->left : t->right, key);
	update_cnt(t);
}
void findpos(pnode& res, pnode t, LL key, LL superkey = 0)
{

	LL s = 1 + superkey + cnt(t->left);
	t->w = s;
	if(!t)
	{
		res = t;
		return;
	}
	if(key < s)
	{
		findpos(res, t->left, key, superkey);
	}
	else
		if(key > s)
		{
			findpos(res, t->right, key, s);
		}
		else
		{
			res = t;
			return;
		}
}
vector<bool> nums;
vector<LL> res;
int ptr = 1;
void printans(pnode& tree)
{
	if(!tree)
	{
		return;
	}
	printans(tree->left);
	if(tree->key <= -1)
	{
		while(!nums[ptr])
			ptr++;
		tree->key = ptr;
		nums.erase(nums.begin());
	}
	res[tree->num] = (tree->key);
	printans(tree->right);
}
int main()
{
	ios::sync_with_stdio(false);
	LL n, m;
	cin>>n>>m;
	nums.assign(n+1, true);
	for(int i = 0; i<n; i++)
	{
		insert(tree, new node(-i-1, rand(), 0, n-1-i));
	}
	vector<pair<LL, LL> > a;
	a.resize(m);
	LL x,y;
	for(int i = 0; i<m; i++)
	{
		cin>>x>>y;
		a[i] = make_pair(x, y);
	}
	pnode pos = nullptr, elem = nullptr;
	pnode l = nullptr, mid = nullptr, r = nullptr;
	for(int i = 0; i<a.size(); i++)
	{
		findpos(pos, tree, a[i].second);
		if(nums[a[i].first])
		{
			if(pos->key <= -1)
			{
				split(tree, pos->w, l, r);
				split(r, 2, mid, r);
				mid->key = a[i].first;
				tree = nullptr;
				merge(tree, l, r);
				merge(tree, mid, tree);
			}
			else
			{
				cout<<-1;
				return 0;
			}
		}
		else
		{
			if(pos->key == a[i].first)
			{
				split(tree, pos->w, l, r);
				split(r, 2, mid, r);
				//mid->key = a[i].first;
				tree = nullptr;
				merge(tree, l, r);
				merge(tree, mid, tree);
			}
			else
			{
				cout<<-1;
				return 0;
			}
		}
		nums[a[i].first] = false;
	}
	res.resize(n);
	printans(tree);
	for(int i = 0; i<res.size(); i++)
	{
		cout<<res[i]<<' ';
	}
	return 0;
}

// Tue Feb 02 2016 00:22:40 GMT+0300 (MSK)

#include<bits/stdc++.h>
using namespace std;
bool used[1000010];
struct Treap
{
    Treap *l,*r;
    int val,sz;
    Treap(){l=r=NULL;val=0;sz=1;}
};
unsigned int x;
unsigned int ran()
{
    return x=x*0xdefaced+1;
}
void pull(Treap *t)
{
    t->sz=1;
    if(t->l) t->sz+=t->l->sz;
    if(t->r) t->sz+=t->r->sz;
}
Treap *merge(Treap *a,Treap *b)
{
    if(!a||!b) return a?a:b;
    if(ran()%(a->sz+b->sz)<a->sz)
    {
        a->r=merge(a->r,b);
        pull(a);
        return a;
    }
    else
    {
        b->l=merge(a,b->l);
        pull(b);
        return b;
    }
}
int size(Treap *t){return t?t->sz:0;}
void split(Treap *t,Treap *&a,Treap *&b,int k)
{
    if(!t) {a=b=NULL;return ;}
    if(size(t->l)+1<=k)
    {
        a=t;
        split(t->r,a->r,b,k-size(t->l)-1);
        pull(a);
    }
    else
    {
        b=t;
        split(t->l,a,b->l,k);
        pull(b);
    }
}
int n,m;
typedef pair<int,int> P;
P opr[1000010];
int a=0;
void print(Treap *t)
{
    if(t->l) print(t->l);
    if(t->val!=0) cout<<t->val<<' ';
    else
    {
        while(a<=n&&used[a]==1) a++;
        cout<<a<<' ';
        a++;
    }
    if(t->r) print(t->r);
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	memset(used,0,sizeof(used));
	Treap *root=NULL;
	for(int i=0;i<n;i++) root=merge(root,new Treap());
    for(int i=0;i<m;i++) cin>>opr[i].first>>opr[i].second;
    bool f=0;
    for(int i=m-1;i>=0;i--)
    {
        int x=opr[i].first,y=opr[i].second;
        Treap *a,*b,*c;
        split(root,a,b,1);
        split(b,b,c,y-1);
        if((a->val==0&&used[a->val]==0)||a->val==x)
        {
            used[a->val]=1;
            a->val=x;
            root=merge(merge(b,a),c);
        }
        else
        {
            f=1;
            break;
        }
    }
    if(f) cout<<-1<<'\n';
    else
    {
        print(root);
        cout<<'\n';
    }
	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

#define sz(v) int(v.size())
#define endl '\n'
typedef long long ll;
typedef pair<int,int> pii;

const int MAXn = 1e6+5;
int val[MAXn+MAXn];
int tree[MAXn*2];
int a[MAXn*2];
int n, m;
bool mark[MAXn];

void inc(int ind, int v = 1) {
	a[ind] += v;
	while(ind <= n+m) {
		tree[ind] += v;
		ind += (ind&-ind);
	}
}

int find(int x) {
	int ind = 0;
	for(int i = 21; i >= 0; i--) {
		ind += (1<<i);
		if(ind > n+m || tree[ind] > x)
			ind -= (1<<i);
		else if(tree[ind] == x) {
			if(a[ind] == 0)
				ind -= (1<<i);
			else
				return ind;
		} else
			x -= tree[ind];
	}
	return ind;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		inc(n+m-i);
	memset(val, -1, sizeof(val));
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		int f = find(y);
		cerr << f << endl;
		if(val[f] != -1 && (val[f] != x || !mark[x])) {
			cout << -1 << endl;
			return 0;
		}
		val[m-i] = x;
		val[f] = x;
		mark[x] = true;
		inc(f, -1);
		inc(m-i, 1);
	}
	int p = 1;
	for(int i = 0; i < n; i++) {
		if(val[m+i+1] == -1) {
			while(mark[p]) p++;
			val[m+i+1] = p;
			mark[p] = true;
		}
	}
	for(int i = 0; i < n; i++)
		cout << val[m+1+i] << " ";
	cout << endl;

	return 0;
}

#include <vector>
#include <stdio.h>
using namespace std;
#define N 1000010
int getint(){
    int x=0; char c=getchar();
    while( c<'0'||c>'9' ) c=getchar();
    while(c>='0'&&c<='9') x*=10,x+=(c-'0'),c=getchar();
    return x;
}
int BIT[ N ];
int n , m , xi , yi , pre , arry[ N ] , now;
int lb( int x ){ return x & (-x); }
void insert( int x ){
    while( x <= n ) BIT[ x ] ++ , x += lb( x );
}
int query( int x ){
    int tsum = 0;
    while( x ) tsum += BIT[ x ] , x -= lb( x );
    return tsum;
}
bool got[ N ];
vector<int> v;
void solve(){
    while( m -- ){
        xi = getint(); yi = getint();
        if( yi <= pre ){
            int tmp = pre - yi , tmp2;
            tmp2 = tmp + query( tmp + 1 );
//            tmp += query( tmp );
            if( xi != v[ tmp2 ] ){
                puts( "-1" ); return;
            }
            insert( tmp + 1 );
            v.push_back( xi );
        }else{
            if( arry[ yi - pre ] ){
                if( arry[ yi - pre ] != xi ){
                    puts( "-1" ); return;
                }
                int tmp = pre - yi , tmp2;
                tmp2 = tmp + query( tmp + 1 );
                insert( tmp + 1 );
                v.push_back( xi );
            }else{
                if( got[ xi ] ){
                    puts( "-1" ); return;
                }
                arry[ yi - pre ] = xi;
                v.push_back( xi ); pre ++;
                got[ xi ] = true;
            }
        }
    }
    int idx = 1;
    for( int i = 1 ; i <= n ; i ++ )
        if( !arry[ i ] ){
            while( got[ idx ] ) idx ++;
            arry[ i ] = idx; idx ++;
        }
    for( int i = 1 ; i <= n ; i ++ )
        printf( "%d%c" , arry[ i ] , i == n ? '\n' : ' ' );
}
int main(){
    n = getint(); m = getint();
    solve();
}
/*
#include <queue>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define N 100010
int getint(){
    int x=0,tmp=1; char c=getchar();
    while( (c<'0'||c>'9')&&c!='-' ) c=getchar();
    if( c == '-' ) c=getchar() , tmp = -1;
    while(c>='0'&&c<='9') x*=10,x+=(c-'0'),c=getchar();
    return x*tmp;
}
int n , m , k[ N ] , cnt , fk , tfk[ N ];
char c[ N ][ 2 ];
bool can[ N ] , in[ N ] , pl[ N ];
queue<int> Q;
void init(){
    n = getint(); m = getint();
    for( int i = 1 ; i <= n ; i ++ )
        can[ i ] = true;
    for( int i = 0 ; i < m ; i ++ ){
        scanf( "%s" , c[ i ] );
        k[ i ] = getint();
        if( c[ i ][ 0 ] == '+' ) pl[ k[ i ] ] = true , cnt ++;
        else if( !pl[ k[ i ] ] ) Q.push( k[ i ] ) , cnt ++ , fk ++ , tfk[ i ] ++;
    }
    for( int i = m - 2 ; i >= 0 ; i -- )
        tfk[ i ] += tfk[ i + 1 ];
}
void solve(){
    if( cnt == n ){
        int mn = 0 , tag = 0;
        for( int i = 0 ; i < m ; i ++ )
            if( c[ i ][ 0 ] == '+' && i == 0 ){
                mn ++; in[ k[ i ] ] = true; tag = k[ i ];
            }
            else if( c[ i ][ 0 ] == '+' ){
                mn ++; in[ k[ i ] ] = true;
                if( mn == 1 && i != 0 && k[ i ] == k[ i - 1 ] &&
                    c[ i ][ 0 ] == '+' && c[ i - 1 ][ 0 ] == '-' )
                        continue;
                can[ k[ i ] ] = false;
            }
            else{
                if( !in[ k[ i ] ] ){
                    if( mn != 0 ) can[ k[ i ] ] = false;
                    continue;
                }
                mn --; in[ k[ i ] ] = false;
                if( mn == 0 && i != m - 1 && k[ i ] == k[ i + 1 ] &&
                    c[ i ][ 0 ] == '-' && c[ i + 1 ][ 0 ] == '+' )
                        continue;
                if( i == m - 1 && tag == k[ i ] );
                else can[ k[ i ] ] = false;
                if( mn != 0 ) can[ k[ i ] ] = false;
            }
    }else{
        int mn = 0 , tag = 0;
        for( int i = 0 ; i < m ; i ++ )
            if( c[ i ][ 0 ] == '+' ){
                if( i == 0 ) tag = k[ i ];
                mn ++;
                if( mn == 1 && i != 0 && k[ i ] == k[ i - 1 ] &&
                    c[ i ][ 0 ] == '+' && c[ i - 1 ][ 0 ] == '-' && tfk[ i ] == 0 )
                        continue;
                in[ k[ i ] ] = true;
                if( mn > 1 || i != 0 || ( i == 0 && fk ) ) can[ k[ i ] ] = false;
            }else{
                if( !in[ k[ i ] ] ){
                    if( mn != 0 ) can[ k[ i ] ] = false;
                    continue;
                }
                mn --; in[ k[ i ] ] = false;
                if( mn == 0 && i != m - 1 && k[ i ] == k[ i + 1 ] &&
                    c[ i ][ 0 ] == '-' && c[ i + 1 ][ 0 ] == '+' )
                        continue;
                if( i != m - 1 || k[ i ] != tag )
                    can[ k[ i ] ] = false;
            }
    }
    vector<int> ans;
    for( int i = 1 ; i <= n ; i ++ )
        if( can[ i ] )
            ans.push_back( i );
    printf( "%d\n" , ans.size() );
    for( int i = 0 ; i < ans.size() ; i ++ )
        printf( "%d%c" , ans[ i ] , i == ans.size() - 1 ? '\n' : ' ' );
}
int main(){
    init();
    solve();
}
*/