#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main()
{
    fastio
    int n, m;
    cin>>n>>m;

    string s(n, '_');

    for(int i = 0; i<m; ++i)
    {
        int si, c;
        cin>>si>>c;
        if(s[si-1]!='_' && s[si-1]!=(c+'0'))
        {
            cout<<-1<<endl;
            return 0;
        }

        s[si-1] = c+'0';
    }

    bool got = false;
    for(int i = 0; i<n; ++i)
    {
        if(s[i] != '_')
        {
            got = true;
        }

        if(s[i] == '_')
        {
            if(got)
            {
                s[i] = '0';
            }
            else
            {
                s[i] = '1';
            }
        }
    }

    if(s==string(n, '0'))
    {
        cout<<-1<<endl;
        return 0;
    }
    cout<<s<<endl;
}