#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> sc(M);
    rep(i, M) cin >> sc[i].first >> sc[i].second;
    sort(all(sc));

    string ans(N, '_');
    for (int d = 1, i = 0, j; d <= N; ++d) {
        for (j = i; j < M; ++j) {
            if (sc[j].first != d) break;
        }
        if (i == j) {
            ans[d - 1] = '0' + (d == 1 ? 1 : 0);
        }
        else {
            ans[d - 1] = '0' + sc[i].second;
            if ((d == 1 && sc[i].second == 0) || (sc[i].second != sc[j - 1].second)) {
                write(-1);
                return 0;
            }
        }
        i = j;
    }
    write(ans);
}