#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin >> n >> m;
    vector<pi> arr;
    map<int,int> ma;
    F0R(i,m)
    {
        int first,second;
        cin >> first >> second;
        first--;
        if((ma.find(first)!=ma.end() && ma[first]!=second) || (first==0 && second==0))
        {
            cout << -1;
            return 0;
        }
        ma.insert({first,second});
        arr.pb({first,second});
    }
    SORT(arr);
    int ind=0;
    F0R(i,n)
    {
        if(ind!=sz(arr) && i>arr[ind].first)
            ind++;
        if(arr[ind].first==i)
            cout << arr[ind].second;
        else
        {
            if(i==0)
                cout << 1;
            else
                cout << 0;
        }
    }

    return 0;
}
