#include <bits/stdc++.h>

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

int n,m,ans[5];
bool vis[6];
map<int,int> mp;

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

    cin >> n >> m;
    bool no=0;
    for(int i=1; i<=m; i++)
    {
        int s,c;
        cin >> s >> c;
        if (mp.find(s) != mp.end() && mp[s] != c) no=1;
        mp[s] = c;
    }

    if (n>1 && mp.find(1) != mp.end() && mp[1] == 0) no=1;
    if (no) return cout << "-1\n" , 0;

    for(auto it :mp)
        ans[it.f] = it.s , vis[it.f]=1;

    for(int i=1; i<=n; i++)
    {
        if (!vis[i])
        {
            if (i==1) ans[i]=1;
            else ans[i]=0;
        }
    }

    for(int i=1; i<=n; i++)
        cout << ans[i];

    return 0;
}