nm = input().split(' ');
n = int(nm[0]);
m = int(nm[1]);

ans = [10]*n;
check = 1;

for i in range(m) :
    sc = input().split(' ');
    s = int(sc[0]);
    c = int(sc[1]);
    if s == 1 and c == 0 and n > 1:
        check = 0;
    elif ans[s-1] < 10 and (not(ans[s-1] == c)) :
        check = 0;
    else :
        ans[s-1] = c;

if ans[0] == 10 :
    ans[0] = 1;
for i in range(1,n):
    if ans[i] == 10:
        ans[i] = 0;

if check :
    for i in range(n) :
        print(ans[i], end="");
    print();
else :
    print(-1);

