#include <bits/stdc++.h>

using namespace std;

int n, m, a[100];
bool check;

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        int s, c;
        cin >> s >> c;
        if (s == 1) check = true;
        if ((a[s] && a[s] != c) || (s == 1 && c == 0 && n > 1)) { cout << -1; return 0; }
        a[s] = c;
    }
    if (!check && n != 1) a[1] = 1;
    for (int i = 1; i <= n; ++i) cout << a[i];
    return 0;
}
