#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n, m;
    cin >> n >> m;
    char ans[n] {'0'};
    bool used[n] {false};
    int s, c;
    bool flag = true;
    for (int i = 0; i < m; i++){
        cin >> s >> c;
        if (used[s-1] && ans[s-1] != c+'0'){
            flag = false;
            break;
        }
        
        used[s-1] = true;
        ans[s-1] = c+'0';
    }
    if (ans[0] == '0'){
        if (used[0]) flag = false;
        else ans[0] = '1';
    }

    if (!flag){
        cout << -1 << '\n';
        return;
    }

    for (int i = 0; i < n; i++){
        if (used[i]) cout << ans[i];
        else cout << '0';
    }
    cout << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}