import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto tmp = new long[](n);
    // writeln(tmp);
    foreach (_; 0 .. m)
    {
        long s, c;
        scan(s, c);
        tmp[s - 1] = c;
    }
    // writeln(tmp);
    if (tmp[0] == 0)
    {
        writeln(-1);
        return;
    }
    long ans;
    foreach (i; 0 .. n)
    {
        ans += tmp[i] * 10 ^^ ((n - 1) - i);
    }
    writeln(ans);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
